Hello. How to write a C program to check and display president party
like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"
Answer / Rahul Goel
Here's a simple C program that accomplishes this. The program uses an array of structs to store names and parties. It then compares the input with the stored names and outputs the respective party.nn```cn#include <stdio.h>nnstruct president {n char name[20];n char party[10];n};nnstruct president presidents[] = {n {"biden", "democrat"},n {"trump", "republican"}n};nnvoid check_president(char input[]) {n int i;nn for (i = 0; i < 2; ++i) {n if (strcmp(input, presidents[i].name) == 0) {n printf("%s is %s
", input, presidents[i].party);n }n }n}nnint main() {n char input[20];n printf("Enter a president's name: ");n scanf("%s", &input);n check_president(input);n return 0;n}n```
| Is This Answer Correct ? | 0 Yes | 0 No |
What are variables c?
int main() { unsigned char a = 0; do { printf("%d=%c\n",a,a); a++; }while(a!=0); return 0; } can anyone please explain me output????
What is the output for the following program #include<stdio.h> main() { char a[5][5],flag; a[0][0]='A'; flag=((a==*a)&&(*a==a[0])); printf("%d\n",flag); }
main() { float a=3.2e40; printf("%d",a); }
write a program without using main function?
What is file in c language?
i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....
How to write the code of the program to swap two numbers with in one statement?
where does it flourished?
whats the use of header file in c?
A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none
Is sizeof a keyword in c?