Input: scanf (“format char”, the address of variable)
Output: printf (“format char”, variable);
Format char
%d - int (decimal system)
%f - float
%c – Char
Assigning Variable
int x=25;printf (“%d”, x); /* o/p obtained = 25. */
(or)
printf(“x=%d”, x); /* x=25 o/p */printf (“%d is the value of x”, x); /* 25 is the value of x */
int x=10, y=40;printf (“%d %d”, x, y); /* 10 40 - o/p */
(or)
printf(“x=%d, y=%d”, x, y); /* x=10, y=40 */printf (“Hello”); /* o/p: Hello */
int x, y;scanf(“%d”,2000) /* Here 2000 is the address of x *//* The address of x is represented as &x */scanf(“%d”, &x);scanf(%d %d”, &x, &y);
Read two integers a and b, find the scan and print the sum
# includevoid main (){int a,b;scanf(“%d%d”, &a,&b);printf(“sum=%d”, a+b);} /* sum = a + b (a,b were given at run time)*/
0 comments:
Post a Comment