Ad

Chapter - 6: Functions And Pointers

Write a function that receives marks received by a student in 3 subjects and returns the average and percentage of these marks. Call this function from main() and print the result in main().


Ad
G
Sections
2
Exercises
#include<stdio.h>
#include<conio.h>

void calc(int, int, int, float*, float*);

int main()
{
	float av, pr;
	int a, b, c;
	printf("Enter the marks of the student in three subjects out of 100 :");
	scanf("%d%d%d", &a, &b, &c);

	calc(a, b, c, &av, &pr);

	printf("\n\nAverage of the marks : %f\n\nPercentage of the student : %f", av, pr);
	getch();
	return 0;
}
void calc(int a, int b, int c, float *av, float *pr)
{
	*av = (a + b + c) / 3;
	*pr = *av / 3;
}
Ad

© 2024 Garbage Valuegarbage value logo