35 : C Program to Calculate total marks and Percentage

Check out the complete list of c-programs : C Program List    



Variables :

We have six integer variables for subjects English, French, Algebra, Geometry, History and Geography to hold user inputted values.

sum : of type integer to hold total marks.

percentage : of datatype float to hold percentage calculated.



Functions :

printf() : is used to display something on the console/screen. Format specifier %d in printf function is used to display a int variable on screen and %f for float. \n is used to add a newline

scanf() : is used to fetch data inputted by the user on the console/screen using keyboard. %d in scanf is indicates that inputted text is of type int.







Formula :

Percentage = (Total x 100)/600

/*
 * 1000+ C programs + tutorials
 *
 * 
 * 35_calculate_total_marks_and_percentage.c
 *
 *
 *  Created on: Oct 20, 2014
 *  Author: Code2care.org
 */

#include 
//#include 



void main() {

   int english,french,algebra,geometry,history,geography;
   int sum;
   float percentage;
  

//    clrscr();

    printf("C Program to Calculate total marks scored in Exams :  ");

    printf("\n\n Enter Marks Scored in English  : ");
	scanf("%d", &english);
    
    printf("\n\n Enter Marks Scored in French  : ");
    scanf("%d", &french);
    
    printf("\n\n Enter Marks Scored in Algebra  : ");
    scanf("%d", &algebra);
     
    printf("\n\n Enter Marks Scored in Geometry  : ");
    scanf("%d", &geometry);
    
    printf("\n\n Enter Marks Scored in History  : ");
    scanf("%d", &history);
    
    printf("\n\n Enter Marks Scored in Geography  : ");
    scanf("%d", &geography);
    
    
    sum = english+french+algebra+geometry+history+geography;
    
    percentage =  (sum*100)/600;
    
    printf("\n\n Total marks scored  = %d /600", sum );
    
     printf("\n\n Percentage Scored  = %f", percentage );



//	getch();


}










The best way to learn C programming is to practice more and more of programs . Code2care C Programming tutorials provide 1000+ programs in C that you can study and become an expert in the language. Programs are divided into categories depending upon type and complexity.

BSc. IT, BSc. Computer Science, BSc. IT, MSc. IT, MSc. Computer Science, MCA, BTech IT & BTech Engineers may find these programs very useful.