#include #include #include #include #include void Q1(); void Q2(); int Prime(int); struct City { int code; char name[100]; int population; }; typedef struct City city; int main() { char option; do { printf("\n\n\n"); printf("\t**************************************************\n"); printf("\t* Selecting appropriate action: *\n"); printf("\t* 1. Question 1 *\n"); printf("\t* 2. Question 2 *\n"); printf("\t* 3. Quit program *\n"); printf("\t**************************************************\n"); _flushall(); printf("\n\tYOUR OPTION IS : "); option=getche(); switch(option) { case '1': Q1(); getch() ; system("cls") ; break ; case '2': Q2(); getch() ; system("cls") ; break ; case '3': return 0; default : getch() ; system("cls") ; printf("\n\n\n\tPlease type the number (1,2,3) again "); } }while(1); } void Q1() { printf("\n\tQuestion 1 \n"); printf("\n\tWrite a program to check whether a number is the prime or not ?\n"); long n; printf("\n\tChecking the prime:\n"); do { printf("\tEnter a number : "); scanf("%d",&n); if (n<1) { system("cls"); printf("\n\tQuestion 1 \n"); printf("\n\tPlease enter the number from 1\n"); }while (n<1) } if (Prime(n)==0 || n==1) { printf("\tThis is not a prime\n"); } else { printf("\tThis is a prime\n"); } } int Prime(int n) { int i; for(i=2;i<=sqrt(n);i++) { if(n%i==0) return 0; } return 1; } void Q2() { printf("\n\tQuestion 2 \n"); int i,n,max ; do { printf("\n\n\tEnter a number of cities (1-10) : "); scanf("%d",&n); if (n<0 || n>10) { system("cls"); printf("\n\tQuestion 2 \n"); printf("\n\tPlease enter the number from 1 to 10\n"); } }while (n<0||n>10); city list[n]; max=0; for(i=0;ilist[i].population)?max:i; } for(i=0;i