Program c menghitung rata-rata nilai mahasiswa

#include <stdio.h>
main()
{
int j,i,m,total=0 ;
float x[10],rata,n;
char nama[10];

printf(“jumlah mahasiswa “);
scanf(“%d”,&m);
for (i=1; i<=m; i++)
{
printf(“nama mahasiswa ke_%d “,i);
scanf(“%s”,&nama);

printf(“jumlah nilai “);
scanf(“%f”,&n);
for (j=1 ;j<=n ;j++){
printf(“nilai ke %d = “,j);
scanf(“%f”,&x[j]);
total=total+x[j];

}}rata=total/n ;

printf(“nilai rata2 %s adalah %2.2f \n”,nama,rata)   ;

}

Advertisements

Leave a Reply

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 / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: