Hello need help with this C++ program

So I am in need for two programs to be created. They are very simple, but I am very poor at C++
here is the questions

write a program that declares and integer named summer and initialize the value to 7. Then print the value of summer to the screen. Next write a statement to increase the value of summer by two. Then print that value to the screen

and the second one is

write a program that will evaluate the expressions below and will print their value (answer) to the screen. You are not to figure out the value, the program is to do that. Store the values as a float.
2 + 6/3 + 1 * 6 - 7
(2+6)/(3+1)*6-7
(2.6)/(3+1)*(6-7)
Thanks, Much appreciated
Read the tutorial on this page

http://cplusplus.com/doc/tutorial/
The first few pages should be enough. Then come back when you have a specific question.
making them for you,, ill post the code soon, but you better learn from it.
There you go,, if this is for a class, this is above and beyond what you asked for and would score an A+ haha.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>     // include the library for the input output stream
#include <windows.h>    // include windows stuff like the PAUSE function

int main()
{
    using namespace std; // always use this

    int summer = 7;     // declaring an integer named summer and immediately
                        //  giving it a value of 7

        cout << "Summer = " << summer << endl << endl; // printing "Summer = " and then the value
                                                        //  of summer. Then ending the line twice (moving down
                                                        //   two lines).

    int summerIncreased = summer + 2;                   // declaring an integer called summerIncreased
                                                        //  and giving it the value of summer and increasing it by 2.


        cout << "Summer increased by two is " << summerIncreased << endl << endl; // printing "Summer increased by two is "
                                                                                  //  and then the value of SummerIncreased to the screen
                                                                                  //   and ending the line twice;

    system("PAUSE"); // pause the program and wait for
                     //  the user to press the enter key.

    return 0;       // return nothing as a result and end the program
}
Last edited on
 
    using namespace std; // always use this no. 


1
2
3
4

    int summerIncreased = summer + 2;                   // declaring an integer called summerIncreased
                                                        //  and giving it the value of summer and increasing it by 2.
//  This isn't increasing the value of summer by 2. 
Last edited on
1.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
     int summer=7;
     cout<<"The value of summer is: "<<summer<<endl;
     summer+=2;
     cout<<"The value of summer increased by 2 is: "<<summer<<endl;
     system ("pause");
     return 0;
     }

2.
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
     float a=2 + 6/3 + 1 * 6 - 7, b=(2+6)/(3+1)*6-7, c=(2.6)/(3+1)*(6-7)
     cout<<"The value of the first expression is: "<<a;
     cout<<"The value of the second expression is: "<<b;
     cout<<"The value of the third expression is: "<<c;


If this isn't for +++A+++ or more, I don't know what is!
Topic archived. No new replies allowed.