C programming language is very popular to programmers. It’s also powerfull. To learn to code C, you’ve to maintain some basic steps. In this article, I’ll show you these steps what are must to run the program. Otherwise, compiler will unable to make output of the witten codes.
How to Learn to Code C
There are some section of a complete C program. First one is the main function. The main function will be written after the following line.
#include<stdio.h>The second line is the main function line. Then we’ve to take second bracket to keep all the codes in this function.
int main()
{ ( Function elements. Such as declaration, initialization, operation and output part) }
In the bracket division, first part is the declareation part where variables are declared. Variable declaration means what type of data you want to take or input. Declaration part would be like the following integer data type declaration.
int a, b, c;
Some of these types of variables are used largely. These are,
Then the initialization part. Different signs like following these are used here to take the variables value.
- int for Integer type.
- double for large
- integer number.
- float for Float type
- char for Character type
The initialization part looks like,
- %d --->>> for decimal number.
- %lf --->>> for float number.
- %f --->>> for long float number.
- %c --->>> for character type value.
scanf(“%d %d %d”, &a,&b,&c);
After initializing the variables, then the operation part. Operation part means, presenting the equation to make output of this program.
Finally, the following line to execute the program.c=a+b;
printf(“Result is : %d”,c);
return 0;
These are the basic parts of a C program. Now write all the codes together on a blank page and run it to see the result.
/* Coding start */
#include<stdio.h>
int main()
{
int a, b, c;
scanf(“%d %d %d”, &a,&b,&c);
c=a+b;
printf(“Result is : %d”,c);
return 0;
}
/* Coding end */
To know well, read the previous articles,
No comments:
Post a Comment