/* My first C program */ // Documentation
#include<stdio.h> // Link section
Here in this program, first commented line is a documentation part that is at the top of program we write the name of program. And after that the second part is a linking section in which we write the header file name. # indicates the current program. By using the #include we included the header file in our current program.
If we create header file for example # include â€œ stdio.hâ€ in these way then it first check present directory that is current directory and if does not find the file in current directory then it will check on root directory.
After that we write the main() function , and when we compile the program the compiler start the compilation from main() function.
clrscr() it is a function these function clear the console screen , printf() it is a output function by using these we print the data on console screen and whatever we write inside of double quote (â€œ â€œ) it will print as it is on console screen. getch() these function hold the screen until and unless you press any key.
Conversion of one datatype to another datatype is known as type casting , C support two types of typecasting:
The conversion does by compiler itself it is called as implicit typecasting.
i1=80.56; /*float converted to int only 80 assigned to i1 */
c2=i1; /*int converted to char */
i2=f1; /*float converted to int */
/*Now c2 has the charecter with ASCII value 80,i2 is assigned value 12 */
printf("\nc2 = %c , i2 = %d",c2,i2);
f2=i1; /*int converted to float */
i2=c1; /*char converted to int */
/*Now i2 contains ASCII value of charecter 'H'which is 72 */
printf("\nf2 = %.2f , i2 = %d",f2,i2);
c2 = p, i2 = 12
F2 = 80.00 ,i2 = 72
Forcefully conversion of one datatype to another datatype is called explicit type casting .That is when we are going to convert any one data type to another data type is called explicit typecasting.
printf("\n p = %.2f",p);
printf("\n q = %.2f",q);
p = 2.00
Q = 2.50