Code Scrappers


Calculate sum of 4 subjects and find percentage C program


              #include<stdio.h>
              #include<stdlib.h>

              void main()
              {
                  int m1, m2, m3, m4, sum;

                  int total = 400;

                  float percentage;

                  printf("Enter marks of 4 subjects out of 100: \n");

                  scanf("%d %d %d %d", &m1, &m2, &m3, &m4);

                  sum = m1 + m2 + m3 + m4;

                  printf("Total Sum : %d\n", sum);

                  percentage = (sum * 100) / total;

                  printf("\nPercentage : %f", percentage);

              }


          



Output

    Enter marks of 4 subjects out of 100:
    78
    95
    100
    98

    Total Sum : 371

    Percentage : 92.000000