what's the wrong with this code ?? ..it doesn't make the prossecc
just typing the marks then nothing !!

//program to get degrees of ten students in exam and compute the average exam degree of them

#include<iostream>
using namespace std;
int main()
{
  int mark,i;
  int average,sum=0;
  cout<<"enter 10 marks :";
  for(i=0;i<=10;i++)
    {
     cin>>mark;
     sum+=mark
    }
  average=sum/i;
  cout<<"average = "<<average<<endl;
  return 0;
}  

Recommended Answers

All 4 Replies

You've missed a semi-colon on line 11.
Your for loop will go round 11 times instead of 10.
Other than that, nothing. If you enter 11 marks you'll get an average mark. What makes you think it doesn't work?

oh the semi-colon wasnt missed in my compiler i typed it .. but may be the reason in my loop ..i forgot that we include 0 while counting .. thxx

is there another way to write this program ??

for(i=0;i<=10;i++) it's 11 iterations
use for(i=1;i<=10;i++) or for(i=0;i<10;i++)

ahaa .. i got it and fixed theat error .. thaaanks so much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.