No errors, but program stops responding when I run it

Wrote this as part of an assignment. It is supposed to use the infinite series for sin, cos, and atan and calculate the sum of a certain number of terms. But whenever I finish feeding it inputs, it stops responding.

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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include <iostream>

using std::cout;
using std::cin;

double sinSeries(int, int);
double cosSeries(int, int);
double atanSeries(int, int);
int factorial(int);

int main(){
    int input, choice, angle;
    double result;
    cout << "This program calculates a number of terms of the infinite series below:\n";
    cout << "1. sine function\n2. cosine function\n3. inverse tangent function\n";
    cout << "Choose a function (1-3): ";
    cin >> choice;
    cout << "Enter the number of terms to calculate: ";
    cin >> input;
    cout << "Enter the angle to calculate: ";
    cin >> angle;
    switch(choice){
         case 1:
              result = sinSeries(input, angle);
              cout << "The result of adding " << input << "terms of the sine function series is ";
              cout << result << "\n";
              break;
         case 2:
              result = cosSeries(input, angle);
              cout << "The result of adding " << input << "terms of the cosine function series is ";
              cout << result << "\n";
         case 3:
              result = atanSeries(input, angle);
              cout << "The result of adding " << input << "terms of the arctangent function series is ";
              cout << result << "\n";
         default:
              cout << "Invalid choice. Program will now close.";
              return 5;
    }
    return 0;
}

double sinSeries(int terms, int number){
    bool addition = false;
    int thingy = 1;
    double outward;
    for(int i = 1; i <= terms; i++){
        if(addition){
        outward += ((number^thingy)/factorial(thingy));
        addition = false;
        }
        else{
        outward -= ((number^thingy)/factorial(thingy));
        addition = true;
        }
        thingy += 2;
    }
    return outward;
}

double cosSeries(int terms, int number){
    bool addition = false;
    int thingy = 0;
    double outward;
    for(int i = 1; i <= terms; i++){
        if(addition){
        outward += ((number^thingy)/factorial(thingy));
        addition = false;
        }
        else{
        outward -= ((number^thingy)/factorial(thingy));
        addition = true;
        }
        thingy += 2;
    }
    return outward;
}

double atanSeries(int terms, int number){
    bool addition = false;
    int thingy = 1;
    double outward = 1;
    for(int i = 2; i <= terms; i++){
        if(addition){
        outward += ((number^thingy)/thingy);
        addition = false;
        }
        else{
        outward -= ((number^thingy)/thingy);
        addition = true;
        }
        thingy += 2;
    }
    return outward;
}

int factorial(int thing){
    int a;
    if(thing = 0){
        return 1;
    }
    for(int i = 1; i <= thing; i++){
         a *= i; 
    }
    return a;
}
line 31 and 35 are missing breaks;
You are using your variable

double outward;

Lines 46 and 64 without initializing them. Same thing with

int a; on line 98

Try that.
Thanks, both of you. Now it returns properly.
Topic archived. No new replies allowed.