Hello, so as I'm preparing for my programming final which is after tomorrow I'll be on this website for the next 48 hours =D
so here I am with a new code that I need a little help in;
so the question is to read 10 marks entered by the user, their values should be between 0 to 20 , and then calculate and display their sum and avg, YES as easy as that;
now after I've finished the code I've noticed that it's accepting any values rather than values between (0-20), how can I fix that , or where's the mistake in the code ,
I tried this problem but in another program and also when I put a mark larger than 20 they accepted !
here my program !
#include <iostream>
using namespace std;
void main()
{
int mark ,count,sum,avg; count=0; sum=0;
while (count<10)
{
do
{
cout<<"Enter amark between 0 and 20"<<endl;
cin>>mark;
}
while (mark<0 || mark>20);
count=count+1;
sum=sum+mark;
}
if (count!=0)
{
avg=sum/count;
cout<<"the average is"<<avg<<endl;
}
system ("pause");
}
and I put (mark>0 && mark<20) it doesn't work !! why that?!