Assignment II

advertisement
Assignment II
Due by 21 Mon October 2013
Question 1.
Write a program that asks for a number and reports the summation from 1 to the
number
Question 2.
Correct the errors in the following programs:
#include<iostream>
using namespace std;
int main_
{
char a;
int x,y;
cin<<x<<y;
a="$";
cout<<x<<y<<a;
return_ ;
}
Question 3.
State the order of the operators in each of the following C++ statement and show the
value of x after each is performed:
 X= 7 % 3 + 8 / 4 % 2 -1;
 x=6 + 2 < 10 && 6/2 ==3 || 10!=10;
Question 4.
Write c++ condition for each of the following statements:
1.
2.
3.
4.
5.
1
Testing a number x is odd.
Y is even and z equal 5.
Testing a string st is the not the same of "Nothing."
x+y is not greater than z and is smaller than 3.
Testing a character c is equal to first letter of your name;
Question 5.
Write a complete c++ program that reads a number then print the number before and
after.
The output should be as following:
Enter a number: 8
The number before is (7) , and the after is (9)
Question 6.
Write program that print an arrow as follows:
*
***
*****
*
*
*
*
Good Luck
Rana Al Abdan
2
Download