Conditional Statements in C
Get Certified in C Programming and Take Your Skills to the Next Level
Program 1
// Program for conditonal statement
#include<stdio.h>
#include<conio.h>
int main()
{
int n;
system("cls");
printf("Enter a number");
scanf("%d",&n);
if(n==1)
printf("One");
if(n==2)
printf("Two");
if(n==3)
printf("Three");
if(n==4)
printf("Four");
if(n==5)
printf("Five");
if(n<0||n>5)
printf("Invalid number pls enter between(1-5)");
return 0;
}
Program 2
// Program for conditonal statement part2
#include<stdio.h>
#include<conio.h>
int main()
{
int n;
system("cls");
printf("Enter a number");
scanf("%d",&n);
// Program for +ive and -ive
if(n>=0)
printf("No is +ive");
else
printf("No is -ive");
// even odd number logic
// if(n%2)
// printf("No is odd");
// else
// printf("No is even");
return 0;
}
Did you like this article? If Yes, please give DataFlair 5 Stars on Google

