tion 3: Choose the correct answer for h of the following questions:

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter2: Basic Elements Of C++
Section: Chapter Questions
Problem 19SA: Which of the following are correct C++ statements? (10) cout "Programming with C++!" endl; cout "...
icon
Related questions
Question
I need the answer quickly
Section 3: Choose the correct answer for
each of the following questions:
Q1. *
If you have the following C++ code segment
int x
switch (x)
case 1:cout<x is 1":
case 2:cout<"x is 2 ";break
default:cout<<"value of x unknown
Choose the correct C++ code segment that produces the same output of the above C++ code segment:
int x:
cin>>x;
if (x-1)
coutee"x is 1"
a)
if (x-2)
cout<<"x is 2 "
if ((x-1)|(x-2))
cout<<value of x unknown
int x:
cin>>x;
if (x-1)
coute<"x is 1 "<"x is 2 ";
if (x-2)
cout<<"x is 2 "
if ((x-1)88(x!-2)
coutee'value of x unknown ";
b)
int x;
cin>>x;
if (x==1)
coute<"x is 1"
if (x-2)
coute<"x is 2 ";
it (x-1)&8(x!-2)
c)
couteevalue of x unknown
":
int x:
cin>>x;
if (x=-1)
cout<<"x is 1";
d)
else
if (x-2)
cout<<"x is 2 ";
el se
coute<"value of x un known ";
a)
b)
Transcribed Image Text:Section 3: Choose the correct answer for each of the following questions: Q1. * If you have the following C++ code segment int x switch (x) case 1:cout<x is 1": case 2:cout<"x is 2 ";break default:cout<<"value of x unknown Choose the correct C++ code segment that produces the same output of the above C++ code segment: int x: cin>>x; if (x-1) coutee"x is 1" a) if (x-2) cout<<"x is 2 " if ((x-1)|(x-2)) cout<<value of x unknown int x: cin>>x; if (x-1) coute<"x is 1 "<"x is 2 "; if (x-2) cout<<"x is 2 " if ((x-1)88(x!-2) coutee'value of x unknown "; b) int x; cin>>x; if (x==1) coute<"x is 1" if (x-2) coute<"x is 2 "; it (x-1)&8(x!-2) c) couteevalue of x unknown ": int x: cin>>x; if (x=-1) cout<<"x is 1"; d) else if (x-2) cout<<"x is 2 "; el se coute<"value of x un known "; a) b)
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr