Write a c program to check a voting AGE condition using conditional/ternary
Q1 Write a c program to check a voting AGE condition
#include <stdio.h>
#include <stdlib.h>
/*
*
*/
int main(int argc, char** argv)
{
int a;
printf("ENTER A AGE\n");
scanf("%d",&a);
a>17 ? printf("YOU CAN VOTE"): printf("YOU CAN'T VOTE");
return (EXIT_SUCCESS);
}
Q2 WRITE A C PROGRAM TO CHECK WEATHER RESULT
#include <stdio.h>
#include <stdlib.h>
/*
*
*/
int main(int argc, char** argv)
{
int a;
printf("ENTER A result");
scanf("%d",&a);
a>32 ? printf("pass "): printf("Better luck next time");
return (EXIT_SUCCESS);
}
Q3 Write a program to check weather a number is positive or negative
#include <stdio.h>
#include <stdlib.h>
/*
*
*/
int main(int argc, char** argv)
{
int a;
printf("ENTER A NUMBER\n");
scanf("%d",&a);
a>=0 ? printf("positive "): printf("negative");
return (EXIT_SUCCESS);
}
Comments
Post a Comment