#include
int main()
{
int n;
printf("enter the number:);
scanf("%d",&n);
/* simple c program output */
printf("number= %d",n);
return 0;
}
All header files are included in this section which contains different functions from the libraries. A copy of these header files is inserted into your code before compilation.
A header file is a file that consists of C declarations that can be used between different files. It helps us in using others’ code in our files. A copy of these header files is inserted into your code before compilation. |
#include
In the structure of a C program, this section contains the main function of the code. The C compiler starts execution from the main() function.
It can use global variables, static variables, inbuilt functions, and user-defined functions. The return type of the main() function can be void and also not necessarily int.
#include
int main()
In simple words, variable is a name given to memory box with a name, where we can “store” some value. Its value can be changed depending upon conditions and it can be reused many times.
S.No | Type | Syntax | Example |
---|---|---|---|
1. | Variable declaration | data_type variable_name; | int x, y, z; char ch; |
2. | Variable initialization | data_type variable_name = value; | int x = 10, y = 20; ch=’l’; |
#include
int main()
{
int n;
The printf()
function is used to display output and the scanf()
function is used to take input from users.
The printf()
and scanf()
functions are commonly used functions in C Language. These functions are inbuilt library functions in header files of C programming.
In C Programming language, the printf()
function is used for output.
printf()
function can take any number of arguments. First argument must be enclosed within the double quotes “hello” and every other argument should be separated by comma ( , ) within the double quotes.
#include
int main()
{
int n;
printf("Enter the number:");
The scanf()
function is used to read input data from the console.
The scanf() function is builtin function available in the C library. scanf()
function can read character, string, numeric & other data from keyboard in C language.
scanf()
reads formatted data from user and assign them in the variables provided the additional arguments. Additional arguments must point to variables that have the same datatype as of user input data format.
#include
int main()
{
int n;
printf("Enter the number:");
scanf("%d",&n);
Comments are the non-executable code used to provide documentation for the C program. Comments provide details about the code so that other users can easily understand the code by reading those comments.
#include
int main()
{
int n;
printf("enter the number:);
scanf("%d",&n);
/* simple c program output */
#include <stdio.h> | This is a preprocessor statement that includes standard input output header file (stdio.h) from the C library. By including header file, you can use many different functions such as printf() |
void main() | The execution of the C program starts with main() function. “void” is the return type of the function. Every C program can have only one main function. |
Braces {} | Two curly brackets {} are used to group all code statements. This indicates begins & ends of the main function. |
/* Comments */ | Comments are just used to document or explain the code, to help others understand it. Everything written inside the command /* */ will be ignored by the compiler. |
printf() | printf() is a function in C, which prints the text output on the screen. |
getch() | This is used to read any character input from the keyboard. |
Learners TV is a website that is designed to educate users and provide instructional material on particular subjects and topics.