Tuesday 1 January 2019

Find result of a student[c programming examples with output]

C programming examples with output

Find result of a student

Program

#include<stdio.h>
#include<conio.h>
main()
{
        int m1,m2,m3,m4,m5,m6,total;
        char result,grade,name[15];
        float avg;
        clrscr();
        printf("Enter student name: ");
        scanf("%s",name);
        printf("\nEnter 6 marks: ");
        scanf("%d%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5,&m6);
        total=m1+m2+m3+m4+m5+m6;
        avg=total/6;
        if(avg>40)
        {
              result= 'P';
        if(avg>75)
             grade='A';
        else if(avg>60 && avg<=75)
             grade='B';
        else if(avg>50 && avg<=60)
             grade='C';
        else
             grade='D';
        }
        else
            result='f';

        printf("\nStudent name  : %s",name);
        printf("\nMarks         : ");
        printf("\n%d\t%d\t%d\t%d\t%d\t%dt",m1,m2,m3,m4,m5,m6);
        printf("\nAverage marks : %f",avg);
        if(result=='p')
            printf("\nResult        : Pass");
        else
            printf("\nResult        : fail");
            printf("\nGrade         : %c",grade);
        getch();
}

Output

Enter student name: Prem
Marks             :
65  69  73  80  90  97
Average result    : 79.000000
Result            : Pass
Grade             : A


Check others programming by click here:
Factorial of a number:
Find sum of digits of a number:
Find vowel or not:
Palindrome Number:

Factorial of a number[c programming examples with output]

C programming examples with output

Factorial of a number

Program
#include<stdio.h>
#include<conio.h>
main()
{
       int a,b,c;
       clrscr();
       printf("Enter any number: ");
       scanf("%d",&a);
       c=a;
       b=1;
       while(c>0)
       {
       b=b*c;
       c-;
       }
       printf("Factorial of %d is:  %d",a,b);
       getch();
}

Output

Enter any number:6
Factorial of 6 is:720


Find sum of digits of a number[c programming examples with output]

C programming examples with output

Find sum of digits of a number

Program

#include<stdio.h>
#include<conio.h>
main()
{
       int a,b;
       long n;
       clrscr();
       printf("Enter any numbr: ");
       scanf("%ld",&n);
       b=0;
       while(n>0)
       {
             a=n%10;
             b=b+a;
             n=n/10;
        }
        printf("The sum of digits is %d",b);
        getch();
}

Output

Enter any number: 45632
The sum of digits is 20

Find vowel or not[c programming examples with output]


C programming examples with output:

Find vowel or not

Program
#include<stdio.h>
#include<conio.h>
main()
{
       char ch;
       clrscr();.
       printf("Enter any charecter: ");
       scanf("%c",&ch);
       switch(ch)
       {
          case 'A':
                  printf("%c is a vowel",ch);
                  break;
          case 'E':
                  printf("%c is a vowel",ch);
                  break;
          case 'I':
                  printf("%c is a vowel",ch);
                  break;
          case 'O':
                  prinntf)'%c is a vowel",ch);
                  break;
          case 'U':
                  printf("%c is a vowel",ch);
                  break;
                  default:
                  printf("%c is not a vowel",ch);
                   }
                  getch();
}

Output

Enter any character: a
a is a vowel
Enter any character: x
x is not a vowel