Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //some lgoical errors, fixing it
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main (){
- int i = 0,v = 0 ,t = 0,a ; //declaration for loop counter, input value, total and average integers;
- /*
- i = counter
- v = value
- t = total
- a = average
- */
- //cin>>v;
- //bool terminate (false);
- while (v =! 99)
- {
- cin>> v; //user input
- if (v < 0 || v>10)
- {
- cout<< "value must be in range of 0 to 10 \n";
- }
- else
- {
- i++;
- t += v;
- }
- };
- if ( i == 0 ) {
- a = 0;
- }
- else {a = t/i;}
- cout<< "average : "<< a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement