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;
}

 

Your 15 seconds will encourage us to work even harder
Please share your happy experience on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *