hello everbody there... i guess everbody is soo fine
this is my first time here in this site i just finished registered right now
i have faced a small problem in my little code, my code is about using recursion in c++ i want to make a small code for students that have 6 subjects
i want to get the sum of those subjects and the average
i have solve how to do the sum of those 6 subjects , but my problem is how to get the average of those subjects
and this is my code
im using turbo c++
Code:
#include <iostream.h>
int subject(int x){
int z, sum = 0 , avg = 0;
if(x<1){
avg = sum / 6;
return avg;
}
else{
cin>>z;
sum = subject(x-1) + z;
return sum;
}
}
void main(){
cout<<subject(6);
}
so i guess that everbody will help me
and thanx alot