suppose x and y are int variables and ch is a char variable. assume the followin
ID: 3616533 • Letter: S
Question
suppose x and y are int variables andch is a char variable. assume the followinginput data: 13 28 D 14 E 98 A B 56 what value is assigned to x, y, and ch after each of thefollowing statements executes? a) cin >> x >> y; cin.ignore (50, ' '); cin >> ch; b) cin >> x; cin.ignore (50, ' '); cin >> y; cin.ignore (50, ' '); cin.get(ch); c) cin >> y; cin.ignore (50, ' '); cin >> x >> ch; d) cin.get(ch); cin.ignore (50, ' '); cin >> x; cin.ignore(50, 'E'); cin >>y; suppose x and y are int variables andch is a char variable. assume the followinginput data: 13 28 D 14 E 98 A B 56 what value is assigned to x, y, and ch after each of thefollowing statements executes? a) cin >> x >> y; cin.ignore (50, ' '); cin >> ch; b) cin >> x; cin.ignore (50, ' '); cin >> y; cin.ignore (50, ' '); cin.get(ch); c) cin >> y; cin.ignore (50, ' '); cin >> x >> ch; d) cin.get(ch); cin.ignore (50, ' '); cin >> x; cin.ignore(50, 'E'); cin >>y;Explanation / Answer
2) 14 E 98 :: only X=14, Y and E do not get anyvalue
3)A B 56 :: None of the variables get any value
b)
1) 13 28 D :: only X will be assigned 13 2) 14 E 98 :: only X wil be assigned to 14
3) A B 56 :: None of the variable get any value
c)
1) 13 28 D :: only Y will be assigned 13 2) 14 E 98 :: only Y will be assigned to 14
3) A B 56 :: None of the variable will be assigned toanything
d)
1) 13 28 D ::only Ch will assigned to '1' (first characterin 13) 2) 14 E 98 :: only CH will be assigned to '1' (first characterin 14)
3) A B 56 :: only CH will be assigned to A
/* program */
#include <iostream>
using namespace std;
int main()
{
int x=0, y=0;
char ch= ' ';
/*
cin>>x>>y;
cin.ignore (50, ' ');
cin >> ch;
cin >> x;
cin.ignore (50, ' ');
cin >> y;
cin.ignore (50, ' ');
cin.get(ch);
cin >> y;
cin.ignore (50, ' ');
cin >> x >> ch;
*/
cin.get(ch);
cin.ignore (50, ' ');
cin >> x;
cin.ignore(50, 'E');
cin >>y;
cout<<endl<<"X:"<<x<<" Y: "<<y<<" CH: "<<ch<<endl;
return 0;
}
2) 14 E 98 :: only X wil be assigned to 14
3) A B 56 :: None of the variable get any value
c)
1) 13 28 D :: only Y will be assigned 13 2) 14 E 98 :: only Y will be assigned to 14
3) A B 56 :: None of the variable will be assigned toanything
d)
1) 13 28 D ::only Ch will assigned to '1' (first characterin 13) 2) 14 E 98 :: only CH will be assigned to '1' (first characterin 14)
3) A B 56 :: only CH will be assigned to A
/* program */
#include <iostream>
using namespace std;
int main()
{
int x=0, y=0;
char ch= ' ';
/*
cin>>x>>y;
cin.ignore (50, ' ');
cin >> ch;
cin >> x;
cin.ignore (50, ' ');
cin >> y;
cin.ignore (50, ' ');
cin.get(ch);
cin >> y;
cin.ignore (50, ' ');
cin >> x >> ch;
*/
cin.get(ch);
cin.ignore (50, ' ');
cin >> x;
cin.ignore(50, 'E');
cin >>y;
cout<<endl<<"X:"<<x<<" Y: "<<y<<" CH: "<<ch<<endl;
return 0;
}
2) 14 E 98 :: only Y will be assigned to 14
3) A B 56 :: None of the variable will be assigned toanything
d)
1) 13 28 D ::only Ch will assigned to '1' (first characterin 13) 2) 14 E 98 :: only CH will be assigned to '1' (first characterin 14)
3) A B 56 :: only CH will be assigned to A
2) 14 E 98 :: only CH will be assigned to '1' (first characterin 14)
3) A B 56 :: only CH will be assigned to A
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.