My first 3 C++ apps

I've been messing around with C++ now for about 4 days about 8-10 hours a day watching tut's like hello world and getting a good understanding of int, if, else, ect... Today thought of putting my new knowledge to a test i made 2 new projects :D

My first was a gun that you could fire with a clip size and ammo
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Code:
#include <iostream>
#include <windows.h>
using namespace std;

int main()

{
        int clip=20;
        int ammo=60;

        cout << "This is ur gun!\n";
        cout << "Press SPACE to fire :D\n";
        Sleep (3000);
        system("cls");

        while(true)
        {

        cout << "\n\n";
        cout << "    clip:" << clip;
        cout << "    ammo:" << ammo;

            if (GetAsyncKeyState(VK_SPACE))
            {
                clip-=1;
                system("color C7");
                Sleep (100);

        if(clip==0)
        {

        system("color 08");

        if(ammo==0)
        {
        break;
        }

        cout << "\n\n  R";
        Sleep (200);
        cout << "E";
        Sleep (200);
        cout << "L";
        Sleep (200);
        cout << "O";
        Sleep (200);
        cout << "A";
        Sleep (200);
        cout << "D";
        Sleep (200);
        system("cls");
        clip+=20;
        ammo-=20;

        }

            }

            system("color 08");
            system("cls");

}

        cout << "\n\nYOUR OUT OF AMMO FUCK OFF :D";
            Sleep(1500);

        char stop;

        cin >> stop;

        return 0;

}

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
28
29
30
Then a calculator
Code:
#include <iostream>

int main()
{

double nUm1;
double nUm2;

for(char cunt;cunt = 'a';)

{
    std::cout << "Give me 2 numbers\n";
    std::cout << "\n1st:";
    std::cin >> nUm1;
    std::cout << "\n2nd:";
    std::cin >> nUm2;
    std::cout << "\nAwswer for divide: " << nUm1/nUm2;
    std::cout << "\nAnswer for times: " << nUm1*nUm2;
    std::cout << "\nAnswer for plus: " << nUm1+nUm2;
    std::cout << "\n\nPress ""a"" to go again: ";
    std::cin >> cunt;
    system("cls");
}

char stop;
std::cin >> stop;
return 0;
}

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Then a stopwatch :P
Code:
#include <iostream>
#include <windows.h>

int main()
{
        int sec;
        int min;
        int hr;
        sec=0;
        min=0;
        hr=0;

        std::cout << "\nUse SPACE to start/stop the stopwatch";

        while(true)
        {
            if(GetAsyncKeyState(VK_SPACE))
            {
                while(true)
                {
                system("cls");
                std::cout << "\nUse SPACE to start/stop the stopwatch\n    "; 
                std::cout << hr;
                std::cout << ":";
                std::cout << min;
                std::cout << ":";
                std::cout << sec;
                sec++;
                Sleep(1000);

                if (sec==60)
                {
        sec=0;
        min++;
                }

                if (min==60)
                {
        min=0;
        hr++;
                }

        {
                if(GetAsyncKeyState(VK_SPACE))
                break;
        }
                }
            }
        }
            char stop;
            std::cin >> stop;
            return 0;

}


Feel free to build urself and drop me some feedback.

I've been told using "system()" is a bad idea for the future but these are only small projects ATM ;) and they don't slow nothing down too much :P

Thx for visiting my post much love <3
closed account (Dy7SLyTq)
yeah system is bad. for future projects i would learn how to do it the c++ way

in gun:
-why are you printing strings back to back on different lines? just curious
- you can make your code smaller and use clip-- instead of clip-=1
-i wouldnt use cin to pause
-finally, in the spirit of learning more, why not try to make a gun class?

in calculator:
-nice job. thats about up to par with the other beginner calculators.
-try modulizing (did i use that right? or would it have to be in a class to be considered modulized?) it all into functions and use a switch

in stopwatch:
really just same as above

but all in all not to bad for a beginner
closed account (N36fSL3A)
Pretty good for your first projects.
Topic archived. No new replies allowed.