C program to read name and marital status of a girl and print her name with Miss or Mrs
In this C program, we will read name and marital status of a girl and print her name Miss or Mrs based on given marital status.
Submitted by IncludeHelp, on March 27, 2018
Given name and marital status of a girl and print her name with Miss and Mrs based on given marital status in C.
Example:
Input:
Enter the name of a girl : Radhika
Is the girl married (Y-Yes, N-No) : yes
Output:
Her full name is : Mrs. Radhika
Input:
Enter the name of a girl : Radhika
Is the girl married (Y-Yes, N-No) : no
Output:
Her full name is : Miss Radhika
In this program, to read strings we are using gets() function - we can also use fgets() function, which is safe.
Syntax:
fgets(string, size, stdin);
In the program, we are checking marital status with following values,
- If input value is "yes" or "y" then, "Mrs" Will be added before the name
- If input value is "no" or "n" then, "Miss" Will be added before the name
- Otherwise, program will print "Marital status is wrong"
Program to print name with Mrs or Miss based on input marital status in C
Output
need an explanation for this answer? contact us directly to get an explanation for this answer