Question #38978

Dear Sir,
i am a student of computer science. i have different these question. Regarding,you replied all answer number #38937 on C++, but i couldn't run, i had found errors. how can i solve these error? i am looking forward your reply. (a)..Declaration syntax error ( using namespace std;). (b). Declaration syntax error ( name space)(c) Declaration syntax error(1-using namespace std;2-undefined symbol 'true'(while (true),(d)Declaration syntax error(1-using name..,2-undefined symbol true(while true). tks.

Expert's answer

#include<iostream> // for cout and cin
#include <stdlib.h>  // for system
using namespace std;
int main()
{
int sum = 0, i = 0;
while (i < 101)
{
sum += i;
i++;
}
cout << "Sum = " << sum << endl;
system("PAUSE");
return 0;
}
#include<iostream> // for cout and cin
#include <stdlib.h>  // for system
using namespace std;
int main()
{
int sum = 0, i = 7;
while (i < 44)
{
sum += i;
i += 4;
}
cout << "Sum = " << sum << endl;
system("PAUSE");
return 0;
}
#include<iostream> // for cout and cin
#include <stdlib.h>  // for system
using namespace std;
int main()
{
int sum = 0, i = 1, numbers = 0;
while (true)
{
++numbers;
sum += i;
i += 2;
if (numbers == 400) break;
}
cout << "Sum = " << sum << endl;
system("PAUSE");
return 0;
}
#include <stdio.h>
#include <iostream> // for cout and cin
#include <stdlib.h>  // for system
using namespace std;
int main()
{
int sum = 0, product = 1, numbers = 0, value;
double average = 0.0;
cout << "Input the numbers the end of input 0" << endl;
while (true)
{
cin >> value;
if (value == 0) break;
++numbers;
sum += value;
product *= value;
average = sum / (double)numbers;
}
cout << "Sum = " << sum << endl;
cout << "Product = " << product << endl;
cout << "Average = "; printf("%.2f", average);
cout << endl;
system("PAUSE");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS