Thursday, August 30, 2018

10. WAP to find the grade a student gets based on the average number obtained using Nested If-Else statement.

10. WAP to find the grade a student gets based on the average number obtained using Nested If-Else statement.
          Avg | Grade
-------------------------
         >=85 |   A
         >=75 |   B
         >=65 |   C
         >=55 |   D
         >=45 |   E
         <45    |   F


#include<stdio.h>
#include<conio.h>
void main()
{
   float eng,maths,phy,chem,comp,avg;
   printf("Enter marks obtained in English: ");
   scanf("%f",&eng);
   printf("Enter marks obtained in Mathematics: ");
   scanf("%f",&maths);
   printf("Enter marks obtained in Physics: ");
   scanf("%f",&phy);
   printf("Enter marks obtained in Chemistry: ");
   scanf("%f",&chem);
   printf("Enter marks obtained in Computer: ");
   scanf("%f",&comp);
   avg=(eng+maths+phy+chem+comp)/5;
   printf("\nAverage number obtained - %.1f",avg);
   if(avg>=85)
   {
    printf("\nGrade - A");
   }
   else
   {
    if(avg>=75)
    {
    printf("\nGrade - B");
    }
       else
       {
if(avg>=65)
{
            printf("\nGrade - C");
        }
          else
          {
             if(avg>=55)
             {
                printf("\nGrade - D");
             }
              else  
              {
                 if(avg>=45)
                {
                      printf("\nGrade - E");
                 }
                  else
                  {
                       printf("\nGrade - F");
                  }
              }   
          }
       }
   }
   getch();
}


OUTPUT:







Please have a look at the below video lesson posted on my YouTube channel:

9. WAP to find the grade a student gets based on the average number obtained.

9. WAP to find the grade a student gets based on the average number obtained.
          Avg | Grade
-------------------------
        >=85 |   A
        >=75 |   B
         >=65 |   C
         >=55 |   D
         >=45 |   E
         <45    |   F


#include<stdio.h>
#include<conio.h>
void main()
{
   float eng,maths,phy,chem,comp,avg;
   printf("Enter marks obtained in English: ");
   scanf("%f",&eng);
   printf("Enter marks obtained in Mathematics: ");
   scanf("%f",&maths);
   printf("Enter marks obtained in Physics: ");
   scanf("%f",&phy);
   printf("Enter marks obtained in Chemistry: ");
   scanf("%f",&chem);
   printf("Enter marks obtained in Computer: ");
   scanf("%f",&comp);
   avg=(eng+maths+phy+chem+comp)/5;
   printf("\nAverage number obtained - %.1f",avg);
   if(avg>=85)
   {
    printf("\nGrade - A");
   }
   else if(avg>=75)
   {
    printf("\nGrade - B");
   }
   else if(avg>=65)
   {
    printf("\nGrade - C");
   }
   else if(avg>=55)
   {
    printf("\nGrade - D");
   }
   else if(avg>=45)
   {
    printf("\nGrade - E");
   }
   else
   {
    printf("\nGrade - F");
   }
   getch();
}



OUTPUT:








Please have a look at the below video lesson posted on my YouTube channel:

8. WAP to find whether an employee will receive bonus or not. Given: The employee will get bonus only if he has been working in the company for more than 3 years. The joining year and current year should be provided by user.

#include<stdio.h>
#include<conio.h>
void main()
{
   int jy,cy,noy,bonus;
   printf("Enter the joining year and current year: ");
   scanf("%d%d",&jy,&cy);
   noy=cy-jy;
   if(noy>3)
   {
    bonus=10000;
    printf("\nEmployee will receive a bonus of Rs. %d "
      "as he has been working for %dyears",bonus,noy);
   }
   else
   {
        printf("\nEmployee will not receive any bonus "
      "as he has been working for %dyears",noy);
   }
   getch();

}


OUTPUT:



Please have a look at the below video lesson posted on my YouTube channel:

7. WAP to calculate whether customer will get discount or not (customer will get discount only if total bill amount is greater than Rs. 100).

#include<stdio.h>
#include<conio.h>
void main()
{
   float amt;
   printf("Please enter total bill amount: ");
   scanf("%f",&amt);
   if(amt>100)
   {
    printf("\nDiscount is applicable.");
   }
   else
   {
    printf("\nDiscount is not applicable.");
   }
   getch();
}


OUTPUT:





Please have a look at the below video lesson posted on my YouTube channel: