Basic Input/Output C Program
Basic Input/Output C Program
Example 1.
// Read a value from standard input
// return 0 tells that program executed successfully
#include<stdio.h> // header file for standard input & output functions
// main function of the program which execute first in every program - starting point
int main()
{
printf("Hello World\n");
// an integer variable declaration
int x;
// Read a value from standard input
scanf("%d", &x);
// Write value to the standard output
printf("%d\n", x);
return 0;
}
Example 2.
#include<stdio.h>
int main()
{
int x=5;
printf("X data is=%d\n", x);
int y=7;
printf("Y data is=%d\n", y);
y=50;
printf("Y data is=%d\n", y);
printf("Address of X is=%u\n", &x);
return 0;
}
Note :- A variable with '&' in prefix represents the address of that variable.
e.g. int x; // variable declaration
'&x' // represents address of the variable x
Comments
Post a Comment