User input in C :
In order to take input form the user and assign it to a variable
➔ we use a function which is known as scanf
Syntax for using scanf :
#include<stdio.h>
int main() {
int i;
scanf("%d", &i); //'&' is the address where given value get stored !
return 0; }
➔ '&' is the address of operator and it means that the supplied value should be copied
to the address which is indicated by variable i .
Program to add two numbers :
#include<stdio.h>
int main() {
// Program to add two numbers :
int num1, num2 ;
printf("Dude! Enter first No. : ");
scanf("%d", &num1);
printf("What about the Second No. : ");
scanf("%d", &num2);
printf("Sum of %d and %d is : %d", num1, num2, num1 + num2);
return 0; }
If you have any query you may Contact Us
Instagram : @akashmacskill