Problem 1 Double r = 2.13; declares that r is a ………………………… Problem 2 cout << “x:
ID: 3577513 • Letter: P
Question
Problem 1 Double r = 2.13; declares that r is a …………………………
Problem 2 cout << “x: “ << r * 2.3; will write …………………………
Problem 3 char c = “4”; declares that c is a …………………………
Problem 4 long t = “3”; declares that t is a …………………………
Problem 5 int b; b = 3.15 * 4.57;
cout << “b: “ << “b”; will write ………………
Problem 6 int c = 3; declares that c is a …………………………
Problem 7 cout << “b: “ << c+5; will write ………………………… (refer to Problem 6)
Explanation / Answer
Problem 1 Double r = 2.13; declares that r is a
If we run Double r = 2.13; its throw error
right syntax is double r = 2.13;
Because c++ is case sensitive.
Problem 2 cout << “x: “ << r * 2.3; will write
If we run Double r = 2.13; then cout << “x: “ << r * 2.3;
This code throw error. Because c++ is case sensitive.
Right syntax is
double r = 2.13;
cout << “x: “ << r * 2.3;
This code Print x: 4.899
Problem 3 char c = “4”; declares that c is a
This code throw error because Character literals not accept double quotes, Character literals always single quotes
Right syntax char c = '4';
Problem 4 long t = “3”; declares that t is a
long t = “3”; not right syntax. SO its throw error.
A long int is a signed integral type that is at least 32 bits
Right syntax is long t = 3;
Problem 5 int b; b = 3.15 * 4.57;
cout << “b: “ << “b”; will write
Its print or return b: b
Because we print b integer type variable in string so.
If we want right answer then syntax
b = 3.15 * 4.57;
int b;
cout << "b: " << b;
Now its print b: 14
Problem 6 int c = 3; declares that c is a
C is a integer type variable and its right syntax.
if we print c variable then its print 3
Second thing we already define char c so if we try again define int c =3;
In this case code throw error.
Problem 7 cout << “b: “ << c+5; will write
If we comment char c = '4'; and run this line with
int c = 3;
cout << "b: " << c+5;
Now its print 8
IF we try with this code
char c = '4';
int c = 3;
cout << "b: " << c+5;
Now its throw error because we already define c variable.
Full ruining code.
#include <iostream>
using namespace std;
int main()
{
double r = 2.13;
//char c = '4';
long t = 3;
int b;
b = 3.15 * 4.57;
int c = 3;
//cout << c;
cout << "b: " << c+5;
//cout << "b: " << b;
//cout << t;
//cout << c;
//cout << "x: " << r * 2.3;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.