How to Create a C Program

Posted on Updated on

Before stating a C program we must have to include some header files which contains some lines of codes and inbuilt methods through which we can easily perform any task in a program and we can’t then we can create our own header file by coding and this will be discussed in further posts.

So, to include header files in c, we have to write something like this :-

=> # is stands for the root directory,
=> include is stands for attaching a header file with program,
=> contains the name of header file with it’s extension .h

stdio.h is a stranded input-output header file,
math.h is for using inbuilt mathematical function in program like, sin, cos etc.

=> every program in c starts with main function and if you want to return some value as a output then you can use the data type of it in the beginning of main function like,
=> int main() -> Returns integer value.
=> void main() -> Returns nothing, not even zero.

Note :- if you have chosen a main function with return type then you must have to return some value in the end of main function like this,
return(5);, return(a); etc.

void main()
Program starts -> {

Program body where the lines of code is written.

Program ends -> }

More will be discussed in next post.


What is variable in c and how to use it?

Posted on Updated on

Variable means a word which holds some memory in computer, according to then type of data the variables types are different. there are many types of variables available in c like Integer, Float, Double, Long double, Char etc.
Syntax(How to define a Variable) : –
1.Variable type 2.Variable name 3.Value of variable(Optional);
Ex:- int A = 10; or int a;
float b = 20.25; or float b;
double c = 30.33333333; or double c;
same for all types of variable.

Note:- The size of memory acquire by a variable is depends upon the variable type.

=> Integer stands for numeric data, a no which doesn’t contain values after point ex :- 10,20,30,40 etc, it occupy 2 bytes in memory and it’s range is -32768 to +32767.

=> float is stands for numeric data, a no with 6 digits of precision ex :- 10.333333, 15.333333 etc, it occupy 4 bytes in memory and it’s range is 1.17549E-38 to 3.40282E+38.

=> double stands for numeric data type which can hold more precision then float and it occupy 8 bytes in memory, The range is 2.22507E–308 to 1.79769E+308.

=> Long double stands for numeric data type and it occupy 10 bytes in memory.

=> Char stands for character data types which allows to store characters like a-z, A-Z, 0-9.
Note:- It can’t be used to store special symbols like $,#,*,^,% etc.

Further will be discussed in Next post………….