4) Show the output produced by the following:
A: int x = 2, y=2;
if( x++>2 || ++y < 3)
cout << x-y ;
else cout << -- y ;
A:This code segment will display a value of: ___
B: int x = 2, y=4;
if( ++x >3 || y++ <= 3)
cout << x*y ;
else cout<< y-x ;
B:This code segment will display a value of: __
C: int x = 2, y=2;
if( ++x >= 3 && y++ <= 3)
cout <
else cout << ++x ;
C: This code segment will display a value of: __
5) What value will the variable sum have after execution of the following code?
int x=3, y=-7, sum =1;
if (( y / x >) > -2 ) sum= x/y ; else sum =y/++x;
6) What value will the variable total have after execution of the following code?
int i = 1, total = 1,x=4 ;
while ( i < 4 ) {
total *= i +x;
--x;
i ++ ; }
4) Show the output produced by the following:
A: int x = 2, y=2;
if( x++>2 || ++y < 3)
cout << x-y ;
else cout << -- y ;
A:This code segment will display a value of: ___
B: int x = 2, y=4;
if( ++x >3 || y++ <= 3)
cout << x*y ;
else cout<< y-x ;
B:This code segment will display a value of: __
C: int x = 2, y=2;
if( ++x >= 3 && y++ <= 3)
cout <
else cout << ++x ;
C: This code segment will display a value of: __
5) What value will the variable sum have after execution of the following code?
int x=3, y=-7, sum =1;
if (( y / x >) > -2 ) sum= x/y ; else sum =y/++x;
6) What value will the variable total have after execution of the following code?
int i = 1, total = 1,x=4 ;
while ( i < 4 ) {
total *= i +x;
--x;
i ++ ; }
4) Show the output produced by the following:
A: int x = 2, y=2;
if( x++>2 || ++y < 3)
cout << x-y ;
else cout << -- y ;
A:This code segment will display a value of: ___
B: int x = 2, y=4;
if( ++x >3 || y++ <= 3)
cout << x*y ;
else cout<< y-x ;
B:This code segment will display a value of: __
C: int x = 2, y=2;
if( ++x >= 3 && y++ <= 3)
cout <
else cout << ++x ;
C: This code segment will display a value of: __
5) What value will the variable sum have after execution of the following code?
int x=3, y=-7, sum =1;
if (( y / x >) > -2 ) sum= x/y ; else sum =y/++x;
6) What value will the variable total have after execution of the following code?
int i = 1, total = 1,x=4 ;
while ( i < 4 ) {
total *= i +x;
--x;
i ++ ; }
Please follow the code and comments for description :
CODE :
a)
#include <iostream>
using namespace std;
int main()
{
int x = 2, y=2; // local variables
if( x++>2 || ++y < 3) // increment and checkk for the value
cout << x-y ; // print the data
else
cout << -- y ;
}
OUTPUT :
2
b)
#include <iostream>
using namespace std;
int main()
{
int x = 2, y=4; // local variables
if( ++x >3 || y++ <= 3) // increment and checkk for the value
cout << x*y ; // print the data
else
cout<< y-x ;
}
OUTPUT :
2
c)
#include <iostream>
using namespace std;
int main()
{
int x = 2, y=2; // local variables
if( ++x >= 3 && y++ <= 3) // increment and checkk for the value
cout <<;
else
cout << ++x ;// print the data
}
OUTPUT :
error: expected primary-expression before \';\' token
Description :
Please replace the value after the cout to print the respective data and then you can get the output.
d)
#include <iostream>
using namespace std;
int main()
{
int x=3, y=-7, sum =1; // local variables
if (( y / x ) > -2 ) // check for the value
sum= x/y ;
else
sum =y/++x; // assign the data
cout << sum; // print the data
}
OUTPUT :
-1
e)
#include <iostream>
using namespace std;
int main() / driver method
{
int i = 1, total = 1, x=4 ; // local variables
while ( i < 4 ) { // iterate over the data
total *= i +x; // assign the data
--x; // function the variables
i++;
}
cout << total;
}
OUTPUT :
125.
Hope this is helpful.