C Program
Example :-
C Program to Check Whether a People is Eligible to Vote or Not
Explain Program
#include <stdio.h>
use input/output library for functions like printf() and scanf().
int main() {
int main is use Start of the main function the execution.
Step :3
int age;
- Declares an integer variable named age.
- used to store the age input by the user
Step :4
printf("enter your age :-");
- Displays the message “enter your age :-” on the screen.
- user to enter their age.
Step :5
scanf("%d", &age);
- Reads an integer input from the user.
- %d tells scanf to expect an integer.
- &age is the address of the variable age, where the entered value will be stored.
Step :6
if (age >= 18)
- user's age greater than or equal to 18.
- If true, it mean the person is eligible to vote.
Step :7
{
printf("you are eligible to vote");
}
- If the condition is true (age >= 18), this message is printed.
Step :8
else {
printf("you are not eligible for vote");
}
- this condition is use false (ie. age < 18) this block run.
- It print the message “you are not eligible for vote”.
No comments:
Post a Comment