First of all we have to know what is scanf? so basically scanf is a function in c programming which we use to input value in console as our wish.
WITHOUT SCANF.
#include<stdio.h>int main(){int a,b,c;a=5; //a and b is integer number.b=10;c=a+b;printf("Sum of the value is = %d",c); // for integer number we use %d.return 0;}
in this code we see a=5 and b=10 .Two numbers add value is 15, so if i want to change the value a and b we have to delete a and b value and type new two value which is so boring. in this problem we can solve by scanf();
WITH SCANF.
#include<stdio.h>int main()
{
int a,b,r;
scanf("%d %d",&a,&b);
r=a+b;
printf("The add value is = %d",r);
return 0;
}
in this code, no a value and no value because we use scanf function. So now i can get input from console as my wish .
Comments
Post a Comment