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().


G
Sections
2
Exercises

A

B

C

D

E

F

G

1

2

3

4

5

6

7

8

9

10

11

12

#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;
}

© 2020 Garbage Valuegarbage value logo