Homework 1
Homework 1
Valid/Not Valid
a) firstC++Prog not valid because identifiers can't use the + sign
b) cin
valid
c) 3feetInAYard
not valid because it starts with a digit
d) _number
valid
e) CPP_Assignment
valid
f) Int
valid
g) Monthly Pay
not valid because you can't put space in identifiers
h) Jack’sHomework
not valid because you can't put ' in identifiers
Q3) Suppose you have the following declarations and statements. (2.5 points)
int x, int y;
double d;
char c1, c2;
cin>>x>>c1>>y>>d;
and you have the following input.
27,8196.2237
What is the output of the following:
Cout<<x<<y<<c1<<c2<<d>>endl;
Error
Q4) you have the following identifiers: (2.5 points)
int x=2.1, y=8, w;
double d=12;
bool b1 =x * 4 -y;
d= d -b1;
w= ++x + (y++) % 4;
What are the values held in x, y, d, and b1 after executing the above statements?
x= 3
y= 9
d= 12
b1= 0
w= 3
Good Luck