MaramAssignment

advertisement
Due 14 Nov
Question 1
Find the errors and correct it:
#include<iostream>
using namespace std;
void main()
{
int x;
cout<<"Please type a number from 1 to 10: ";
cin>>x;
if(x=5);
cout<<"\nYou typed my favorite number!"<<endl;
else;
cout<<"\nThank you and goodbye"<<endl;
}
Question 2:
Write a statement (or comment) to accomplish each of the following
(assume that using declarations have been used):
a. State that a program calculates the product of three integers.
b. Declare the variables x, y, z and result to be of type int (in separate
statements).
c. Prompt the user to enter three integers.
d. Print "The product is " followed by the value of the variable result.
e. Return a value from main indicating that the program terminated
successfully.
1
Question 3:
Which of the following is a correct C++ identifier:
SS
N1
budget
A$total2
D_D
ThisIsAlongOne
So_is_this_one
It's
S-3
into
Xyz123
_amount
2ndclass
bool
Question 3 - Declare the following using one statement:
double x;
double y;
double z;
char a = ‘i’;
char b;
char c = ‘E’;
Question 4:
A) Write two constant declaration to hold the number of days in a
week and the number of weeks in two months using both const
and define for each ?
B) Write declaration statements to declare integer variables ( i) and (
j ). Then, extend your declarations so that (i ) and (j) are both
initialized to 1 .
2
3
Download