write program to accept a number(use scanf [ ]) and check whether it is greater than 5 or not. Use of elsa and write two outputs
fast please
Answers
C Program
We have to write a program to accept a number and check whether it is greater than 5 or not.
We are all aware if a number, say num is:
- Greater than 5 if num > 5
- Smaller than 5 if num < 5
First, we shall ask the user to input a number and store it in the num variable.
We have three simple statements through which can determine if a given number is greater or smaller than 5 or equal to 5.
- If statement
- Else if statement
- Else statement
The Program
#include <stdio.h>
int main()
{
int num;
printf("Enter a number: ");
scanf("%d", &num);
if (num > 5) {
printf("The entered number is greater than 5.");
}
else if (num < 5) {
printf("The entered number is smalled than 5.");
}
else {
printf("The entered number is equal to 5.);
}
return 0;
}
Sample Run
Here are three sample runs of the above program:
- First run
Enter a number: 7
The entered number is greater than 5.
- Second run
Enter a number: 3
The entered number is smaller than 5.
- Third run
Enter a number: 5
The entered number is equal to 5.
To read a brief explanation/description about C Program, refer to the link below:
brainly.in/question/42822183