Write a c program to check a voting AGE condition using if-else
Q1 Write a c program to check a voting AGE condition
Given age of someone and that we ought to check whether person is eligible for voting or not.
To check that someone is eligible for voting or not, we'd like to examine whether or not person’s age is bigger than or up to eighteen. For this we tend to are reading age in a very variable a and checking the condition a>=18, if the condition is true, "person are eligible for voting" else no.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
int a;
printf("ENTER
A AGE\n");
scanf("%d",&a);
if (a>=18)
{
printf("YOU CAN VOTE");
}
else
{
printf("YOU CAN'T VOTE");
}
return
(EXIT_SUCCESS);
}
ANS -
#include <stdio.h>Q2 WRITE A C PROGRAM TO CHECK WEATHER RESULT
The Given marks of student and that we ought to check whether student is pass or fail.
To check that student is pass or fail ,we'd like to examine whether or not student marks is greater then or up to thirty-three. For this we tend to are reading marks in a very variable a and checking the condition a>=33, if the condition is true, "student is pass or fail.
#include <stdlib.h>
/*
*
*/
int main(int argc, char** argv)
{
int a;
printf("ENTER A RESULT\n");
scanf("%d",&a);
if(a>=33)
{
printf("pass ");
}
else
{
printf("pending");
}
return (EXIT_SUCCESS);
}
Q3-Write a program to check weather a number is positive or negative
ANS -
#include <stdio.h>
#include <stdlib.h>
/*
*
*/
int main(int argc, char** argv)
{
int a;
printf("ENTER A NUMBER\n");
scanf("%d",&a);
if(a>=0)
{
printf("positive ");
}
else
{
printf("negative");
}
return (EXIT_SUCCESS);
}
Comments
Post a Comment