Friday, March 7, 2014

WRITE A FUNCTION THAT ACCEPTS MARKS OBTAINED BY A STUDENT IN 3 SUBJECTS AND RETURNS THE AVERAGE AND PERCENTAGE OF THE MARKS

#include<conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
void cal(int*,float*,float*);
int ar[3],i;
float avg,per;
clrscr();
printf("enter the marks out of 50\n");
for(i=0;i<3;i++)
{
scanf("%d",&ar[i]);
}
cal(ar,&avg,&per);
printf("\nthe avg of marks is %f",avg);
printf("\nthe percentage of marks is %f",per);
getch();
}

void cal(int *a,float *avg,float*per)
{
int i,s=0;
for(i=0;i<3;i++)
{
s=s+*(a+i);
}
*avg=s/3;
*per=s*100/150;
}




No comments:

Post a Comment