Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

getting wrong O/P for find average code using function

$
0
0
i have written code to find average and percentage using function and pointer. but the output is going wrong.
example - average for 50, 50 and 51 is 50.

#include<stdio.h>
#include<conio.h>
void avgper (int,int,int,float *,float *);
main ()
{
     int i,j,k;
     float per,avg;
     printf("\t\t LUC - 5 - d - f - c - average and percentage in one fuction\n\n");
     printf("Enter your three subjects marks ");
     scanf("%d %d %d",&i,&j,&k);
     avgper (i,j,k,&per,&avg);
     printf("\nYour average marks = %f",avg);
     printf("\nYour percentage = %f",per);
     getch();
     }
     void avgper (int i,int j,int k,float *l,float *m)
     {
     *l=(i+j+k)*100/300;
     *m=(i+j+k)/3;
     }



Posted Image

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>