C++ statements

Write C++ statements that accomplish each of the following:

a. Declare and initialize int variables x to 25 and y to 18.
b. Declare and initialize an int variable temp to 10 and a char variable ch to 'A'.
c. Add 5 to the int variable x which already exists.
d. Declare and initialize a double variable payRate to 12.50. e. Copy the value from an existing int variable firstNum into an existing int variable tempNum.
f. Swap the contents of existing int variables x and y. (Declare any new variables you need.)
g. Output the contents of existing double variables x and y, and also output the value of the expression x + 12 / y - 8.
h. Copy the value of an existing double variable z into an existing int variable x.

You can check these out:
- http://www.cplusplus.com/doc/tutorial/variables/
- http://www.cplusplus.com/doc/tutorial/operators/

Or ask me to post a code to meet you needs...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
int x=25, y=18;
int temp = 10;
char ch = 'A';
x += 5;
double payRate = 12.50;
tempNum = firstNum;

// #include <algorithm>
std::swap(x, y);

// #include <iostream>
std::cout << x << '\t' << y << '\t' << x + 12 / y - 8 << std::endl;

x = z;

closed account (4SyAqMoL)
Hey, I'm happy that I can do...most of that! :)
Topic archived. No new replies allowed.