Exercise 7[C],Let Us C Solution

1 min read


 Exercise 7[C]

Write  program to find the grace marks for a student using switch.
The user should enter the class obtained by the student and the number
of subjects he has failed in.Use the following loigc:
--If the student gets first class and the number of subjects he failed in
is greater than 3,then he does not get any grace.Otherwise the grace is
of 5 marks per subjcet.
--If the student gets second class and the number of subjects he failed
in is greater than 2,then he does not get any grace.Otherwise the grace
is of 4 marks per subjects.
--If the student gets third class and the number of subjects he failed
in is greater than 1,then he does not get any grace.Otherwise the grace is
of 5 marks.           */
#include<stdio.h>
int main()
{
	int div,sub;
	printf("Enter the class obtained by the student:");
	scanf("%d",&div);
	printf("Enter the number of subject in which he has failed:");
	scanf("%d",&sub);
	switch(div)
	{
		// for first class student
		case 1:
			if(sub<=3)
			printf("He got the grace of %d marks",5*sub);
			else
			printf("He didn't get any grace marks");
			break;
			case 2:
			if(sub<=2)
			printf("He gots the grace of %d marks",4*sub);
			else
			printf("He didn't get any grace");
			break;
			// for Third class student
			if(sub<=1)
			printf("He got the grace of %d marks",5*sub);
			else
			printf("He didn't get any grace");
			break;
	}

return 0;}
Welcome to prgrmramit.blogspot.com! I'm Amit Singh, an expert in AI, Data Science, and Machine Learning. I created this blog to share practical insights and tips for those eager to learn and gro…

You may like these posts

  •  PROBLEM 6.1Write a program to print all prime numbers from 1 to 300. */ #include<stdio.h> int main() { int i,n=1; printf("\nPrime numbers between 1 and 300 are:\n\t"…
  •  Exercise[6B(b)]According to a study,the approximate level of intelligence of person can be calculated using the following formula: i=2+(y+0.5x) Write a program that will pr…
  •  Exercise [B(a)]Write a program to print the multiplication table of the number entered by the user.The table should get displayed in the following form: 29*1=29 29*2=58 ...…
  •  /* PROBLEM 6.2Write a program to add first seven terms of the following series using a for loop. 1/1!+2/2!+3/3!+.... */ #include<stdio.h> int main() { int i=1…
  •  PROBLEM 6.3Write a program to generate all combinations of 1,2 and 3 using for loop. */ #include<stdio.h> int main() { int i=1,j=1,k=1; for(i=1;i<=3;i++) { fo…
  •  Exercise[6B(c)]When interest compunds q times per year at an annual rate of r% for n years,the principle p compounds to an amount a as per the following formula a=p(1+r/q)^nq…

Post a Comment

Subscribe with Gmail


Premium By Raushan Design