Correct the errors and show the output of following the program: | Sololearn: Learn to code for FREE!

0

Correct the errors and show the output of following the program:

#include<iostream.h> void main( ) { char count = 1; int sum = 0; while ( count <= 25 ) { sum = sum + count; count = count + 2 cout << “sum is: “ << sum << endl; }

4/10/2021 12:57:17 PM

pro.shahad *

3 Answers

New Answer

+1

You declared count as a character change it to 'int'

+1

In the name of kindly generous ALLAH Thanks ALLAH your wrongs: 1-you must include iostream without .h so #include<iostream> 2-the (original)main mathod returns a value by int type and a value must be returned(for default 0 and then stopped this method and does not resume for statements those are after return statement so int main(){ //your statements that you want to run return 0; //statements does not run in here(after returning) } 3-in 9th line you must ends statement by a semicolon(;) so count+=2; 4-in 10th line in cout you must use any string in double quotes(") but it is not double quot so cout<<"sum is:"<<sum<<endl; 5-you are using pieces of std namespace then you must use any attrib or method such as std::endl; but you can declare once for all using by using namespace std;(in the middle of includes and main method) so #include<iostream> using namespace std; int main(){...} 6-a curly brace have missed you add it at the end of your whole code so ... int main(){ for(...){ ... } } the end:)

0

https://code.sololearn.com/cKH6cFrlpvfS/?ref=app