Page 322 - C++
P. 322
(c) Rewrite the following C++ code after removing any/all syntactical
errors with each correction underlined. 2
Note : Assume all required header files are already included in the
program.
Typedef Count int;
void main()
{
Count C;
cout<<"Enter the count:";
cin>>C;
for (K = 1; K<=C; K++)
cout<< C "*" K <<endl;
}
(d) Find and write the output of the following C++ program code : 3
Note : Assume all required header files are already included in the
program.
void Revert(int &Num, int Last=2)
{
Last=(Last%2==0)?Last+1:Last-1;
for(int C=1; C<=Last; C++)
Num+=C;
}
void main()
{
int A=20,B=4;
Revert(A,B);
cout<<A<<"&"<<B<<endl;
B--;
Revert(A,B);
cout<<A<<"#"<<B<<endl;
Revert(B);
cout<<A<<"#"<<B<<endl;
}
91 3 P.T.O.