Programming structure of C language Reviewed by Momizat on . A c programming can be clarified into 6 basic elements.which are furnished below. Example of Programming structure // My first program ............(1) #include A c programming can be clarified into 6 basic elements.which are furnished below. Example of Programming structure // My first program ............(1) #include Rating: 0

Programming structure of C language

A c programming can be clarified into 6 basic elements.which are furnished below.

Example of Programming structure

// My first program ............(1)
#include  ..............(2)
#include  ....
main()...........................(3)
{................................(4)
	clrscr();.....................
	printf("My first program");.........(5)
	getch();......................
}...............................(6)
  • 1) Remark statement:-It is mainly use to put some additional information in the program. A remark statement doesn’t compile by compiler.Thus,we can type anything in it there are two types of remark statements.
    1)
    // comments ...

    (double slash) single line comment or remark statement.
    2)

    /* ...comments.*/

    (slash with star for opening and star with back slash for closing) Multiple line comment or remark statement.

  • 2) Processor directive:-C programming provides a wide list of functions,keyword and inbuilt objects and their prototype and declaration in various header file.So, It is very necessary to define the require header file at the beginning of the program The input and output statement of program by the header file and it is define like as Ex:-
    #include <stdio.h>; or #include "stdio.h";
  • 3) Main function declaration:-C language is a function oriented programming language.where the user must define at list function and function name must be ‘main’.The main function may or may not require arguments.Ex:-
    #include <stdio.h>;
    main()
    
  • 4) Main function open:-After declaration of main function we must open with the opening chain bracket. Ex:-
    #include <stdio.h>;
    main(){
    
  • 5) Main function body:-The body of main function is the main mechanism of C statement.The C compiler first executes the other function for units.If It is linked with the main function.Ex:-
    #include <stdio.h>;
    main(){
    ....body....
    ....body....
    
  • 6) Main function close:-Finally the body of the main function terminates with the closing chain bracket.
    #include <stdio.h>;
    main(){
    ....body....
    ....body....
    }
    

Input and Output of C programming

For the basic input and output operations The following functions

  • scanf():- It is the input function of C language which accept data value from the user and assign it in respective identify.
    //Syntax:-scanf("formate of datatype",variable);
    int n;
    Scanf("Enter a number :%d",&n);
    char m;
    scanf("%c",m);
    
  • printf():- It is display any message or value of any variable in output screen.
    // Syntax:-printf("message %formate",variable);
    int n=2;
    printf("My first programme");
    printf("%d",n);
    printf("Number is:%d",n);
    
  • gets():- It is used to string inputted function of C.which accept a complete string with blank space and assign.it is a string variable.
    //syntax:-gets(variable);
    
    char s[9];
    gets(s);
    
  • puts():- It is used to display the value of a string variable in output screen.
    //syntax:-puts(variable);
    
    puts(s);
    

if statement in C language

if(condition){
	::::::::::::
	statements
	:::::::::::
}else if(condition){
	::::::::::::
	statements
	:::::::::::
}else{
	::::::::::::
	statements
	:::::::::::
}

Switch statement in C language

switch(expression){
case value:
	::::::::::::
	statements
	:::::::::::
	break;
case value:
	::::::::::::
	statements
	:::::::::::
	break;
case value:
	::::::::::::
	statements
	:::::::::::
	break;
:::::::::::::::::
:::::::::::::::::
default:
	::::::::::::
	statements
	:::::::::::
	break;
}

go to statement in C language

goto <label name>;
	::::::::::::
	statements
	:::::::::::
<label name>:

Loop statement in C language

for loop
for(initialization;condition;updation){
	::::::::::::
	statements
	:::::::::::
}
while loop
while(condition){
	::::::::::::
	statements
	:::::::::::
}
dowhile loop
do{
	::::::::::::
	statements
	:::::::::::

}while(condition);

Leave a Comment

© 2014 Powered By