#include <stdio.h>
#include <conio.H>
void main()
{
int a,b,c,d,e,f,g,i,h;
float p;
char A[10];
clrscr();
printf("Enter the name\n");
gets(A);
printf("Enter the ENG marks\n");
scanf("%d",&a);
printf("Enter the HIN marks\n");
scanf("%d",&b);
printf("Enter the MAR marks\n");
scanf("%d",&c);
printf("Enter the MAT marks\n");
scanf("%d",&d);
printf("Enter the SCI marks\n");
scanf("%d",&e);
printf("Enter the S.S marks\n");
scanf("%d",&f);
g=a+b+c+d+e+f;
p=(g*100)/600; // <<-----
printf("NAME\t ENG\t HIN\t MAR\t MAT\t SCI\t S.S\t TOTAL\t PERCENTAGE\n");
printf("%s\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %f\n",A,a,b,c,d,e,f,g,p);
getch();
}
The program works fine except for the line marked. What’s the problem with it?
Convert to float before division