Exercises 3
Exercises 3
3.1
a- true
b-true
c- false , Because the expression x>y and a<b both must be true not one of both is true
d-true
-----------------------------------------------------------------------------------------------------------------------------------------
3.2
a-
int sum=1;
cout <<" sum of the odd integers between 1 and 99" << endl;
b-
#include <iostream>
#include <cmath>
#include <iomanip>
int main()
cout << fixed << setprecision (1) << left << setw (15) << value;
cout << setprecision (3) << setw (15) << value << endl;
return 0;}
c-
#include <iostream>
#include <cmath>
#include <iomanip>
int main()
double value;
cout << fixed << setprecision (2) << setw (10) << value << endl << endl;
return 0;
d-
int x=1;
{ cout << x;
if (x % 5 == 0)
else
x++;
cout << x;
if (x % 5 == 0)
else
cout<< endl;
------------------------------------------------------------------------------------------------------------------------------------------
3.3
a-
int x = 1;
while ( x <= 10 )
cout << x;
x++;
b-
int n;
cin >>n;
switch (n)
{ case 1:
break;
case 2:
break;
default:
break;}
d-
int n = 1;
while ( n < 11 )
(or)
int n = 1;
while ( n <= 10 )