Greetings.....
Starting with the first program!!!
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Hello Universe!!!");
getch();
}
The above program is the one that is very basic.
Compile the above program for errors. If there is no error then run it. The output will be like this
#include<stdio.h>
This is called as headerfile that is mandatory and must for all the programs that are being written in C language. <stdio.h> depicts that the C compiler has some standard input and output functions that are to be called to use in this program and .h represents that it is a headerfile.
To use printf() and scanf() functions these headerfile is mandatory.
stdio - Standard Input Output
#include<conio.h>
This is another headerfile that represents Console input output. This is used in compilers like turbo c++. But the modern compilers does not need this.
To use clrscr() and getch() this headerfile is mandatory to be written before main function.
clrscr() - used to clear the previously executed output from the output console screen
getch()- used to view the console screen. without this the screen will not be static.
If clrscr() is not used then the second execution of the program will result like,
Look in to that the previous output is not cleared
void main()
void main() is called as the main function that is must for all C programs. The compiler first checks from this main function once the program is executed. Thus this is the starting of any C program. Function should return a value. If it is not going to return any value then "void" keyword is used before main().
The same program can be written like
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
printf("Hello Universe!!!");
return 0;
getch();
}
Here instead of "void", "int"(data type) is used. This means the function returns an integer value.
So, the return 0; is used in the last. Both will give the same result.
printf("xyz");
Printf() is a library function that is used to display the output for the given input. Whatever you give inside the double quotes will be displayed in the console screen. Semi colon must be used at the end for all the statements used inside the functions except for conditional statements. This represents the end of the statement inside the function.
In the next post, we will see about the variable declaration.
Thank you.......... :)
Starting with the first program!!!
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Hello Universe!!!");
getch();
}
The above program is the one that is very basic.
Compile the above program for errors. If there is no error then run it. The output will be like this
#include<stdio.h>
This is called as headerfile that is mandatory and must for all the programs that are being written in C language. <stdio.h> depicts that the C compiler has some standard input and output functions that are to be called to use in this program and .h represents that it is a headerfile.
To use printf() and scanf() functions these headerfile is mandatory.
stdio - Standard Input Output
#include<conio.h>
This is another headerfile that represents Console input output. This is used in compilers like turbo c++. But the modern compilers does not need this.
To use clrscr() and getch() this headerfile is mandatory to be written before main function.
clrscr() - used to clear the previously executed output from the output console screen
getch()- used to view the console screen. without this the screen will not be static.
If clrscr() is not used then the second execution of the program will result like,
Look in to that the previous output is not cleared
void main()
void main() is called as the main function that is must for all C programs. The compiler first checks from this main function once the program is executed. Thus this is the starting of any C program. Function should return a value. If it is not going to return any value then "void" keyword is used before main().
The same program can be written like
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
printf("Hello Universe!!!");
return 0;
getch();
}
Here instead of "void", "int"(data type) is used. This means the function returns an integer value.
So, the return 0; is used in the last. Both will give the same result.
printf("xyz");
Printf() is a library function that is used to display the output for the given input. Whatever you give inside the double quotes will be displayed in the console screen. Semi colon must be used at the end for all the statements used inside the functions except for conditional statements. This represents the end of the statement inside the function.
Thank you.......... :)
No comments:
Post a Comment