Learn C ProgrammingLearn ProgrammingPrograms On Decision Control StructuresResources

024. Write a Program to accept user’s marital status, gender and age to check if he/she is eligible for marriage or not.

By September 18, 2012 February 5th, 2018 One Comment
#include<stdio.h>
#include<conio.h>  
main()
{
   int age;
   char MaritalStatus,Gender;
   clrscr();
 printf("Enter MaritalStatus, Gender, Age : (e.g. m,f,25) : ");
   scanf("%c,%c,%d",&MaritalStatus,&Gender,&age);
   if(MaritalStatus=='m')
   {
		printf("You can not marry!");
   }
   else if(MaritalStatus=='u')
   {
		if(Gender=='m')
		{
			if(age>=21)
			    printf("You can marry!");
			else
			    printf("You can not marry!");
		}
		else if(Gender=='f')
		{
			if(age>=18)
			    printf("You can marry!");
			else
			    printf("You can not marry!");
		}
		else
		      printf("Invalid input Gender");
   }
   else
printf("Invalid input Marital Status ");
   getch();
}


One Comment

Leave a Reply

DEMO01