1#include <stdio.h>
2
3int main()
4{
5 int a, b, c;
6 printf("Enter the first value:");
7 scanf("%d", &a);
8 printf("Enter the second value:");
9 scanf("%d", &b);
10 c = a + b;
11 printf("%d + %d = %d\n", a, b, c);
12 return 0;
13}
14
1/* scanf example */
2#include <stdio.h>
3
4int main ()
5{
6 char str [80];
7 int i;
8
9 printf ("Enter your family name: ");
10 scanf ("%79s",str);
11 printf ("Enter your age: ");
12 scanf ("%d",&i);
13 printf ("Mr. %s , %d years old.\n",str,i);
14 printf ("Enter a hexadecimal number: ");
15 scanf ("%x",&i);
16 printf ("You have entered %#x (%d).\n",i,i);
17
18 return 0;
19}