my program stops working please help

this is my program
#include <iostream>
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
char exit;
int choice;
string getinput;

do {
menu:
system ("CLS");
cout << "---Menu---" << endl;
cout << "1: Calculator" << endl;
cout << "2: Farenheit to Celsius convertor" << endl;
cout << "3: Matrix" << endl;
cout << "4: Quit" << endl;
cin >> choice;
switch (choice)
{
case 1:
int x,y,ans;
int choice;;
char loop;
ans=0;

system ("CLS");

do
{
printf("\n Do you wish to continue (Y/N) : ");
scanf_s("%s",&loop);

if (loop=='y' || loop=='Y')
{
system ("CLS");
printf("\n Enter any two numbers ");
printf("\n --------------------- ");

printf("\n\n Enter the first number : ");
scanf_s("%d",&x);

printf("\n Enter the second number : ");
scanf_s("%d",&y);

system ("CLS");
printf("\n Select the operation to be carried out ");
printf("\n -------------------------------------- ");

printf("\n 1. Addition ");
printf("\n 2. Substraction ");
printf("\n 3. Multiplication ");
printf("\n 4. Division ");

printf("\n Enter your choice : ");
scanf_s("%d",&choice);

switch(choice)
{
case 1 :
{
ans = x+y;
printf("\n Answer = %d",ans);
break;
}
case 2 :
{
ans = x-y;
printf("\n Answer = %d", ans);
break;
}
case 3 :
{
ans = x*y;
printf("\n Answer = %d", ans);
break;
}
case 4:
{
ans = x/y;
printf("\n Answer = %.2f", ans);
break;
}
default:
printf("\n\n Illegal operation......");
break;
}
}
if(loop=='n'){
goto menu;
}
}while(loop=='y' || loop=='Y');

case 2:
system ("CLS");
int celsius, farenheit;

cout << "\nwhat is the temparture in farenheit? ";
cin >> farenheit;
celsius = 5 * (farenheit - 32) / 9; //farenheit formula

cout << "\nThe temperture in celsius is ";
cout << celsius;
cout << " degrees celsius" << endl;
system ("PAUSE");
goto menu;

case 3:
system("CLS");
int R;

/* initialize random seed: */
srand ( time(NULL) );
for (;;)
{
/* generate secret number: */
R = rand() % 2 ;
cout << R;
}
case 4:
system("CLS");
cout << "If you wish to exit press 'e' then enter" <<endl;
cout << "If you wish to return to the main menu press 'r' then enter" <<endl;
cin >> exit;
}
}while (exit != 'e');
if (exit == 'e'){
return 0;
}
}
when you use the calculator then enter n the program stops working any ideas why and any ideas how to fix the problem please help me
Could you be more specific as to what you mean by "stops working"? And use [code][/code] tags around your code, please.
by stoped working i mean when i run the program go to the calculator and enter no a message pops up saying that a problem has caused the program to stop working sorry about the code not being in the code tags im new
Here are several things you wish to consider:
- try to limit yourself at one I/O channel, don't mess up with booth iostream and stdio
- try to avoid labels and unconditional jumps (goto statements), "normal" loops should be enough for your level
- in a switch statement, usually each individual case is delimited by a break statement, otherwise you swith through all possible values and the swith itself becomes (almost) useless
- don't initialize inside switch statement (look here and read the "Note": http://msdn.microsoft.com/en-us/library/66k51h7a(v=vs.80).aspx)

I'll try again your code, but first clean it up a little bit.
thxs ill try to clean it up
Topic archived. No new replies allowed.