How to write a simple C program ?
Hi , friends C is a very easy and important language to learn. A simple C program consist of some main()
function , Header files , and body for the program.
header files
main function
{
variable;
executable -program;
}
Example
#include<stdio.h> //header files
#include<conio.h>//header files
void main() // main function
{
clrscr(); // this will clear the screen remove previous programs output
printf("hello , I am learning C language\n"); /* this command will print “hello , I am learning C language”*/
getch();// it allows to see output till you press any key
}
this program will print "hello , I am learning C language" in output
Rules for writing C program
- every statement in C ends with semi colon.
- header files should start with “#”.
- Every main function program should be written in Braces “{}”.
No comments:
Post a Comment