A. Asks a student if he/she is full-time or part-time.
B. If the student is full-time, the program will ask for the student's major and print the input for major followed by "is a good major" to the screen. If the student is not full-time, the program will ask the student how many credits he/she is taking. If the student is taking more than 6 credits, the program will print "That is a lot for a part-time student" to the screen. If the student is taking 6 or less credits, the program will print "That is nice" to the screen.
C Program
1.First Way
#include <stdio.h>
#include <stdlib.h>
int main()
{
int sel,major;
printf("press\n1.if you are full time\n2.if you are part time\n");
scanf("%d",&sel);
printf("How many major do you have:");
scanf("%d",&major);
if(sel==1)
printf("is a good major");
else if(sel==2 && major<6)
printf("Thats nice");
else
printf("That is a lot for a part-time student");
}
2.Second Way
#include <stdio.h>
#include <stdlib.h>
int main()
{
int sel,major;
printf("press\n1.if you are full time\n2.if you are part time\n");
scanf("%d",&sel);
printf("How many major do you have:");
scanf("%d",&major);
if(sel==1)
{
printf("is a good major");
}
else
{
if(major<6)
printf("Thats nice");
else
printf("That is a lot for a part-time student");
}
}
3.Third Way
#include <stdio.h>
#include <stdlib.h>
int main()
{
int sel,major;
printf("press\n1.if you are full time\n2.if you are part time\n");
scanf("%d",&sel);
printf("How many major do you have:");
scanf("%d",&major);
switch(sel)
{
case 1: printf("is a good major");
break;
case 2: if(major<6)
{
printf("Thats nice");
}
else
{
printf("That is a lot for a part-time student");
}
break;
}
}
I remember this question it was my question during c Practical exam
ReplyDelete