Ex: write to a C program to check given number is zero or not. C program to check given number is zero or not. How to write a C program to print it is zero or not.
Input from user:
Enter the number: 0
Expected output:
Given number is zero.
1. First we will accept input number from user say no.
2. After that use if-else statement to check condition no==0 .
3. If this condition true then print given number is zero.
4. Otherwise we print given number is not zero.
#include<stdio.h>
int main()
{
int no;
printf("Enter the number\n");
scanf("%d",&no);
if(no==0)
{
printf("Given number is zero");
}
else
{
printf("Given number is not zero");
}
return 0;
}
Above program shows the following output:
Input from user:
Enter the number: 0
Expected output:
Given number is zero.
Step by step logic of the given program:
1. First we will accept input number from user say no.
2. After that use if-else statement to check condition no==0 .
3. If this condition true then print given number is zero.
4. Otherwise we print given number is not zero.
C Program to check given number is zero or not :
#include<stdio.h>
int main()
{
int no;
printf("Enter the number\n");
scanf("%d",&no);
if(no==0)
{
printf("Given number is zero");
}
else
{
printf("Given number is not zero");
}
return 0;
}
Above program shows the following output:
No comments:
Post a Comment
If you have any doubts, please discuss here...👇