Skip to main content

another example of if-else-if ladder in C

#include<stdio.h>
int main()
{
   int age;
   printf("Enter your age\n");
   scanf("%d",&age);
   if (age>=18)
   {
      printf("you can vote");
   }
   else if (age<14)
   {
      printf("you can vote for kids");
   }
   else
   {
      printf("you can,t vote sorry!");
   }
   
   
   return 0;
}


//we can also do like this
#include<stdio.h>
int main()
{
   int age;
   printf("Enter your age\n");
   scanf("%d",&age);
   if (age>=18)
   {
      printf("you can vote");
   }
   else if (age==1,2,3,4,5,6,7,8,9,10,11,12,13,14)
   {
      printf("you can vote for kids");
   }
   else
   {
      printf("you can,t vote sorry!");
   }
   
   
   return 0;
}


Comments