➨Reading input Data :-
- The scanf() library function can be used for entering input data.
- This function can take all type of values (numeric,character,string) as input.
Scanf function can be written as:-
scanf("control string",address1, address2,......);
- Function should have at least two parameters.
- First parameter is control string, which contains conversion specifications character. And it should be also in double quotes.
- Conversion specification characters may be one or more than one , it depends on the no. of variables we want to input.
- The other parameters are addresses of variables.
- The address of variable is found by preceding the variable name by an ampersand(&) sign.
- Ampersand (&) is called the address of operator and it gives the starting address of the varibale name in memory.
- A string value is not preceded by an & sign to get the address.
examples:-
#include<stdio.h>
void main()
{
int marks;
.........
scanf("%d",&marks);
.........
}
In this example, %d impllies that one integer value is entered and stored in marks variable.
➨Writing output Data:-
- The printf() function can be used for printing output data.
- By this function all types of values(numeric, character or string) can be written as output.
Printf() function can be written as:-
printf("control string" ,varibale1 ,variable2,...);
- The control strings contains conversion specifications characters and text.
- It should be enclosed within double quotes.
- The name of variables should not be preceeded by an ampersand (&) sign.
some examples are:-
1.
#include<stdio.h>
void main()
{
printf("Saurav singh");
}
output: Saurav singh
2.
#include<stdio.h>
void main()
{
int marks=90;
.......
printf("%d",marks);
......
}
output: 90
3.
#include<stdio.h>
void main()
{
int marks=90;
printf("Total marks=%d",marks);
}
output: Total marks=90.
Good
ReplyDeleteI appreciate your comment
Delete