Use of conditional Operators




#include <stdio.h>  

#include<conio.h>

int main()  

{  

    int age;  // variable declaration  

    printf("Enter your age");  

    scanf("%d",&age);   // taking user input for age variable  

    (age>=18)? (printf("eligible for voting")) : (printf("not eligible for voting"));  // conditional operator  

    return 0;  

}  


Output:-

Enter your age13

not eligible for voting


Enter your age19

eligible for voting

Comments

Popular posts from this blog

Check whether the no entered is Palindrome or not

Calculate Factorial of a given no with help of Recursion

Find max. and min. element in the integer array