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.
getch()
function are used for to wait and get any character
from user.
#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();
}
User enter integer value storing in num
and printing num
value.
&
are used for storing user Enter value in Variable.
#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();
}
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.
#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();
}
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.
#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();
}