Input from User in C

User input in C programming are used to take input from user, scanf() is one of the commonly used function to take input from user and proceed with that value.

Program Working with Getch Function

getch() function are used for to wait and get any character from user.

Program

#include<stdio.h>
#include<conio.h>
void main()
{
printf("Please Enter any Key to Continue\n");
getch();
printf("Please Enter any Key again to Continue\n");
getch();
printf("Please Enter any Key to Exit");
 getch();
}
Output
Please Enter any Key to Continue
Please Enter any Key again to Continue
Please Enter any Key to Exit

Program User Entered value Printing

User enter integer value storing in num and printing num value.
& are used for storing user Enter value in Variable.

Program

#include<stdio.h>
#include<conio.h>
void main()
{
int num;
printf("Enter a number: ");
scanf("%d", &num);
printf("You have just entered the number %d", num);
getch();
}
Output
Enter a number: 5
You have just entered the number 5

Program Adding User Entered Values and Printing

User enter Integer value storing in a and b and adding these values and assigning to c and printing c value on the output screen.

Program

#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, c;
printf("Please Enter First Integer\n");
scanf("%d", &a);
printf("Please Enter Second Integer\n");
scanf("%d", &b);
c = a + b;
printf("The Answer is: %d", c);
getch();
}
Output
Please Enter First Integer
5
Please Enter Second Integer
6
The Answer is: 11

Program Using Math Library for Power

Assigning 3 Power 2 to a and printing a value on the output screen.
Working with Power will be needed to include math.h library.

Program

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a;
a = pow(3, 2);
printf("3 Power 2 is: %d", a);
getch();
}
Output
3 Power 2 is: 9