Most C programs are in lower case letters. You will usually find upper case letters used in preprocessor definitions or inside quotes as parts of character strings.
C programming language is case sensitive, that is, it recognises a lower case letter and it's upper case equivalent as being different.
all program statements in c must be terminated by a semicolon.
First C program
| First C program |
#include < stdio.h >
int main()
{
printf("hello world\n");
return 0;
}
|
A c program whatever may its size,consists of functions and varibles. A function contains statements that specifies the computing operations to be done and variables store values during the computation.
Let's take a look at our first C program.
main is a special function that every program begins executing at the begining of main.The open and closed parantheses immediately fallowing main specify that no arguments or parameters are expected by this function.
int main() tells that the return type of the main function is of type int.
{ }
The 2 curly brackets are used to group all the commands together so it is known that the commands belong to main. These curly brackets are used very often in C to group things together.
If a line starts with a hash, denoted by # is expanded by the preprocessor.
#include
tells the compliler to include the information about the standard input/output library.
printf function simply prints or displays its argument at the terminal.
\n -(newline charecter) tells the compiler to print a newline as part of the output.
return 0;
The int in int main() is short for integer which is another word for number. We need to use the return command to return the value 0 to the operating system to tell it that there were no errors while the program was running.
The text between the /* and */ is ignored by the compiler.