LAB RECORD PROGRAM NO -1

1.Write a C Program to demontate the Ternary Operator.

#include <stdio.h>

#include<conio.h>

void main() 

{

 int age;

 // take input from users

 printf("\nEnter your age: "); 

 scanf("%d", &age); 

 // ternary operator to find if a person can vote or not

 (age >= 18) ? printf("You can vote") : printf("You cannot vote"); 

getch(); 

}

Comments

Popular posts from this blog