Академический Документы
Профессиональный Документы
Культура Документы
ND
15/22 2 FLOOR ASHOK NAGAR ND-18 (PH – 55711031, 9810378235)
c) The following statement is illegal why? How would you correct it?
main( )
{
int i = j = k = 0 ;
}
b) Consider
// version 1 // version 2
. .
. .
. .
while ( ch ! = ‘&’) while ( ch ! = ‘&’)
{ {
cin>> ch ; cin >> ch ;
if ( ch = = ‘ ‘ ) if ( ch = = ‘ ’ )
Spaces ++ ; Spaces ++ ;
If ( ch = = ‘\n’) else
Newlines ++ ; if ( ch == ‘\n’)
Newlines ++;
} }
. .
. .
. .
What advantages, if any, does the second version have over the first?
b) Write output of
# include<iostream.h>
void main()
{
long number = 5572331, result = 0 ;
do
{
result * = 10 ;
int digit = number % 10 ;
result + = digit ;
number/ = 10 ;
} while (number)
cout<<”output = ” <<result<< endl ;
}