#include<stdio.h>
main()
{
int a,x,y,z;
clrscr();
printf("Select from the following operation:");
printf("1]Addtion");
printf("2]Subtraction");
printf("Enter your choice here:");
scanf("%i",&z);
switch(z)
{
case 1:
    printf("Enter Num 1:")
    scanf("%i",&x);
    printf("Enter Num 2:")
    scanf("%i",&y);
    a=x+y;
    printf("%i + %i  = %i",x,y,a);
    break;

case 2:
    printf("Enter Num 1:")
    scanf("%i",&x);
    printf("Enter Num 2:")
    scanf("%i",&y);
    a=x-y;
    printf(" %i - %i  = %i",x,y,a);
    break;

default:
    printf("Not in the menu!);
    break;
}

umm.. ,:twisted:
so how will i make it to return to the menu after the execution of a case or default??..:twisted::P

what loop will i use or how to make it a nested one??:twisted:

William Hemsworth commented: Learn to post. -1
yellowSnow commented: Lazy sod! +0
Ancient Dragon commented: No code tags -5

Recommended Answers

All 7 Replies

while(1)
{
    printf("Select from the following operation:");
    printf("1]Addtion");
    printf("2]Subtraction");
    printf("3]EXIT"); /*new statement*/

    printf("Enter your choice here:");
    scanf("%i",&z);

    if(z==3)
         break;
 
   switch(z)
    {
         case 1:
                  /*your code*/
          /*more cases*/
    }
 }

Great, after three threads of being told to post the code, you don't use code-tags :icon_confused:
Please, read the rules too.

aahahaha!

im not really in on reading rules

sorry!


im a newbie and just first year in my class so sorry to all disappointment!


^_^!

im glad to join this forum!!

commented: No! -1
commented: LOL... we don' need no stinkin' rules!!! -1

im glad to join this forum!!

Glad to have you too :P but code tags here is a must. All you have to do when writing your post is:

blah blah blah, and the code i'm currently struggling with is:

[code] CODE HERE [/code]

I'm sure you can manage that.

aahahaha!

im not really in on reading rules

sorry!


im a newbie and just first year in my class so sorry to all disappointment!


^_^!

im glad to join this forum!!

Mmm ... you're not really into reading rules. There are many members of this forum who won't be "really into helping you out" with that attitude. You'll get no "sweet sympathy" here with that modus operandi. Being a newbie and in first year is no excuse ... it just sounds like you're plain lazy.

Trust me; if you keep those types of responses going, you'll be subconsciously blacklisted before you know it (meaning - most members will choose to ignore you in the future). It's working for me already.

Going by your other posts, you may also take a little time to give your posts appropriate titles as well ... "here's the code" and "plz help" are crap titles for threads.

aahahaha!

im not really in on reading rules

Than I can't be bothered to help you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.