class - Returning 0 with classes + switch -


while messing around using switches , class, understand them, come problem im not understanding.

in code im trying do, it's work out life path, if don't know life paths are, adds numbers of birthdate work out, eg if born on 13th of august, in 1980 13 = 1 + 3 = 4, 8 = 8, 1980 = 1 + 9 + 8 + 0 = 18 = 1 + 8 = 9, 4 + 8 + 9 = 21 = 2 + 1 = 3, life path 3.

but im using cases switch statements inside, find right numbers use, looking in day class(you'll see below), i'll run code, , it'll go write case, when returning value of day, returns 0. wanted know how fix this. thanks.

#include <iostream>  using namespace std;    int day(int day) {     cout << "please enter day of month born" << endl << "if born on number sixth, please enter 06" << endl << endl;     cin >> day;      switch (day)     {         cout << " day : ";     case(01):         cout << "01 = 1" << endl;         break;     case(02):         cout << "02 = 2" << endl;         break;     case(03):         cout << "03 = 3" << endl;         break;     case(04):         cout << "04 = 4" << endl;         break;     case(05):         cout << "05 = 5" << endl;         break;     case(06):         cout << "06 = 6" << endl;         break;     case(07):         cout << "07 = 7" << endl;         break;     case(8):         cout << "08 = 8" << endl;         break;     case(9):         cout << "09 = 9" << endl;         break;     case(10):         cout << "10 = 1 + 0 = 1" << endl;         day = 1;         break;     case(11):         cout << "11 = 1 + 1 = 2" << endl;         day = 2;         break;     case(12):         cout << "12 = 1 + 2 = 3" << endl;         day = 3;         break;     case(13):         cout << "13 = 1 + 3 = 4" << endl;         day = 4;         break;     case(14):         cout << "14 = 1 + 4 = 5" << endl;         day = 5;         break;     case(15):         cout << "15 = 1 + 5 = 6" << endl;         day = 6;         break;     case(16):         cout << "16 = 1 + 6 = 7" << endl;         day = 7;         break;     case(17):         cout << "17 = 1 + 7 = 8" << endl;         day = 8;         break;     case(18):         cout << "18 = 1 + 8 = 9" << endl;         day = 9;         break;     case(19):         cout << "19 = 1 + 9 = 10 = 1 + 0 = 1" << endl;         day = 1;         break;     case(20):         cout << "20 = 2 + 0 = 2" << endl;         day = 2;         break;     case(21):         cout << "21 = 2 + 1 = 3" << endl;         day = 3;         break;     case(22):         cout << "22 = 2 + 2 = 4" << endl;         day = 4;         break;     case(23):         cout << "23 = 2 + 3 = 5" << endl;         day = 5;         break;     case(24):         cout << "23 = 2 + 4 = 6" << endl;         day = 6;         break;     case(25):         cout << "25 = 2 + 5 = 7" << endl;         day = 7;         break;     case(26):         cout << "26 = 2 + 6 = 8" << endl;         day = 8;         break;     case(27):         cout << "25 = 2 + 7 = 9" << endl;         day = 9;         break;     case(28):         cout << "25 = 2 + 8 = 10 = 1 + 0 = 1" << endl;         day = 1;         break;     case(29):         cout << "29 = 2 + 9 = 11 = 1 + 1 = 2" << endl;         day = 2;         break;     case(30):         cout << "30 = 3 + 0 = 3" << endl;         day = 3;         break;     case(31):         cout << "31 = 3 + 1 = 4" << endl;         day = 4;         break;     default:         cout << "invalid selection, please try again." << endl;         day(day);     }      return day; }  int month(int month) {     cout << "please enter month of year born" << endl << endl;     cin >> month;      cout << "month : ";     switch (month)     {     case(1):         cout << "01 = 0 + 1 = 1" << endl;         break;     case(2):         cout << "02 = 0 + 2 = 2" << endl;         break;     case(3):         cout << "03 = 0 + 3 = 3" << endl;         break;     case(4):         cout << "04 = 0 + 4 = 4" << endl;         break;     case(5):         cout << "05 = 0 + 5 = 5" << endl;         break;     case(6):         cout << "06 = 0 + 6 = 6" << endl;         break;     case(7):         cout << "07 = 0 + 7 = 7" << endl;         break;     case(8):         cout << "08 = 0 + 8 = 8" << endl;         break;     case(9):         cout << "09 = 0 + 9 = 9" << endl;         break;     case(10):         cout << "10 = 1 + 0 = 1" << endl;         month = 1;         break;     case(11):         cout << "11 = 1 + 1 = 2" << endl;         month = 2;         break;     case(12):         cout << "12 = 1 + 2 = 3" << endl;         month = 3;         break;     default:         cout << "invalid selection, please try again." << endl;         month(month);     }     return month; }  int year(int year) {     cout << "please enter year born" << endl << endl;     cin >> year;      return 0; }  int lifenumber(int day, int month, int year, int lifenumber) {      return 0; }  int main() {      int day = 0, month = 0, year = 0, lifenumber = 0;      day(day);      month(month);      cout << "day : " << day << " | month : " << month << endl;      year(year);      lifenumber(day, month, year, lifenumber);       return 0; } 


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -