Answer questions according to C 1 What is wrong with the fol


Answer questions according to C++

1. What is wrong with the following code segment(it is not a program) a. cin

Solution

1. Here in this both the statements are wrongly defined.

For cin in C++ we use >> symbol to take input , << is used to print anything using cout.

Also in the second statement we need to write the condition of if in parantheses . But here directly written. Also semicolon usage is also wrongly defined. For else there should be no semicolon but for the other declarative statemetns we need to use semicolon.

The correct statements for the given are :-

a. cin >> count;

b. if (x < y)

min =x ;

else

min y;

2.

The logical Operators in C++ are &&,||, !

a. (height >=7.7 && height< 9.2)
b. (letter = \'Y\' || letter = \'y\')
c. ! (( x * 5 ) = 25)
d. (donation > 3000 && donation < 5000 || guest = 5)


3. To output anything in the C++ we use COUT statement.

cout <<\" My dog\'s name is Maggie\" <<\"\ \";
cout << \" I also have a cat named Senatra\"

4. The float value result is 1.66667


Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site