#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:

Edited 3 Years Ago by Dani: Formatting fixed

Comments
No code tags
Lazy sod!
Learn to post.
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*/
    }
 }

Edited 7 Years Ago by dkalita: n/a

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!!

Comments
LOL... we don' need no stinkin' rules!!!
No!

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.

Edited 7 Years Ago by yellowSnow: n/a

This article has been dead for over six months. Start a new discussion instead.