ภาษา C ++โปรแกรมเกรดเฉลี่ยแบบไม่วนลูป

#include
#include
void main()
{
float cr1,sc1,sum1=0,cr2,sc2,sum2=0,cr3,sc3,sum3=0,credit3=0;
clrscr();
textcolor(14);
gotoxy(25,5);
cprintf(“<<<<<<<..PROGRAM GPA..>>>>>>>n”);
printf(“n”);
printf(“n”);

printf(“::Subject1::n”);
printf(“n”);
printf(“Credit : “,cr1);
scanf(“%f”,&cr1);
printf(“Grade : “,sc1);
scanf(“%f”,&sc1);
sum1=sum1+(cr1*sc1);
printf(“n”);
printf(“————————n”);

printf(“n”);
printf(“::Subject2::n”);
printf(“n”);
printf(“Credit : “,cr2);
scanf(“%f”,&cr2);
printf(“Grade : “,sc2);
scanf(“%f”,&sc2);
sum2=sum2+(cr2*sc2);
printf(“n”);

printf(“————————n”);

printf(“n”);
printf(“::Subject3::n”);
printf(“n”);
printf(“Credit : “,cr3);
scanf(“%f”,&cr3);
printf(“Grade : “,sc3);
scanf(“%f”,&sc3);
sum3=sum3+(cr3*sc3);
credit3=cr1+cr2+cr3;
printf(“n”);

printf(“————————n”);
printf(“Average of grade = %.2fn”,(sum1+sum2+sum3)/credit3);
printf(“————————n”);
getch();
}

ใส่ความเห็น

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out / เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out / เปลี่ยนแปลง )

Google+ photo

You are commenting using your Google+ account. Log Out / เปลี่ยนแปลง )

Connecting to %s

%d bloggers like this: