First of all
if(ch1=0)
does not do what you think it does.
It does not check if the value of ch1 is 0, but it assigns the value 0 to ch1. Then checks, if the expression is true. The expression is the value of ch1 (after assignment), that is, 0. An integral number is interpreted as true, if the value is not 0. But since it is 0, if (ch1 = 0) evaluates to false all the time.
That being said, the right code is checking for equality, not assigning value, which is written using double equal signs:
if (ch1 == 0)
So, your question: how to stop execution at a given point and return back to the original menu? Well, there's no original menu to return to in a sense that the program starts, asks a question then does something and quits.
What you could do is create a loop around the main code: asking for an option, asking for the numbers, and doing arithmetics with them:
#include<stdio.h>
int main()
{
int a, b, ch, c; // declaration of variables of integer type
do
{
printf("\n\t Menu");
printf("\n\t ====")
printf("\n\t 0. End the program");// added a new option, which is 0, that will end the program after confirmation.
printf("\n\t 1. Addition");
printf("\n\t 2. Subtraction");
printf("\n\t 3. Multiplication");
printf("\n\n\t Enter Your Choice: ");
scanf("%d", &ch); // getting value from user for ch
if (ch <= 3 && ch > 0) // if the value of ch is not between 0 to 3 it will print the default case
{
printf("Enter two numbers: ");
scanf("%d %d",&a,&b);
}
switch(ch)
{
case 0:
printf("Are you sure you want to exit?\n If yes, press 0. If not, press any other number.");
scanf("%d", &ch); //getting value from user for ch2
if (ch == 0)
{
printf("End the program");
}
break;
case 1: // code to be executed if "ch=1"
c = a + b;
printf("\n Addition: %d",c);
break;
case 2: // code to be executed if "ch=2"
c = a - b;
printf("\n Subtraction: %d", c);
break;
case 3: // code to be executed if "ch=3"
c = a * b;
printf("\n Multiplication: %d", c);
break;
default: // code to be executed if ch doesn't match with any cases
printf("\n Invalid Choice");
break;
}
} while (ch != 0);
return 0;
}
The added loop is marked with yellow.
Please note, that you do not need to change when numbers need to be entered for arithmetic operations (marked with purple) when you add your quit option.
Your quit logic is best handled inside the switch case, so I moved it there and marked it with turquoise. Please notice that you do not need ch2 either, you can just use the original ch when you ask for confirmation. If the user enters 0, that is the same as the original menu item 0, so we could store it in the same ch variable.
I hope this helps.