Scanf :
The scaf function is an input function , that take the input for the value for the character types in c programming, saves in the the memory address of that dada type and perform action or other implementation on it
The syntax for the function is
Scanf("%d or %c , ( of the data type you are taking) ",$...of the value you want it to be stored in);
for example, if we are taking an integer and storing its value in a.
then :
scanf("%d",&a);
The syntax for the function is
Scanf("%d or %c , ( of the data type you are taking) ",$...of the value you want it to be stored in);
for example, if we are taking an integer and storing its value in a.
then :
scanf("%d",&a);
A basic program to introduce the function :
#include<stdio.h>
#include<conio.h>
void main(void)
{
int a,b,s;
clrscr();
printf("Enter the value for a: ");
scanf("%d",&a);
printf("\nEnter the value of b: ");
scanf("%d",&b);
s=a+b,
printf("\nThe answer after adding is : %d\n\n\n\n\tProgram made by programmer Sami Ullah",s);
getch();
}
In this we took three sets of integers a , b and s , int a we stored the value of 'a' and in int b we stored the value of 'b' and then we took an other integer where we stored the value of there sum and applying the sum formula on "a+b" and assigning the int s its value.
No comments:
Post a Comment