Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C: Else misplaced.
#1
Code:
#include "stdio.h"
#include "conio.h"
#include "math.h"
void welcome();
#pragma startup welcome
#pragma warn-rch
int main()
{
int a,b,c,menu;
printf("Enter 1,2,3 or 4\n\n");
printf("1.Addition\n");
printf("2.Subraction\n");
printf("3.Division\n");
printf("4.Multiplication\n");
scanf(" %d",&menu);
if(menu==1)
{
printf("Enter any two no.s\n");
scanf(" %d%d",&a,&b);
goto add;
}
else if(menu==2)
{
printf("Enter any two no.s\n");
scanf(" %d%d",&a,&b);
goto sub;
}
else if(menu==3)
{
printf("Enter any two no.s\n");
scanf(" %d%d",&a,&b);
goto div;
}
else if (menu==4)
{
printf("Enter any two no.s\n");
scanf(" %d%d",&a,&b);
goto multi;
}
add:
c=a+b;
printf("Addition of two no. is = %d\n",c);
div:
c=a/b;
printf("Division of two no. is = %d\n",c);
multi:
c=a*b;
printf("Multiplication of two no. is = %d\n",c);
sub:
c=a-b;
printf("Subraction of two no. is = %d\n",c);
getch();
return 0;
}
void welcome()
{
printf("Danger -- Welcomes you!\n\n");
}
The code is not fully done yet still working but this error annoying meh. OR should I use switch at place of ifelse

Double post

Guys the else done now help me getting out I mean


Code:
add:
c=a+b;
printf("Addition of two no. is = %d\n",c);
div:
c=a/b;
printf("Division of two no. is = %d\n",c);
multi:
c=a*b;
printf("Multiplication of two no. is = %d\n",c);
sub:
c=a-b;
printf("Subraction of two no. is = %d\n",c);

So all get printed I want the one I choose .......


GOT THE SOLUTION MYSELF!!
[Image: 629965_101.png][Image: dav8ugf75d010z8vovm.gif]

Messages In This Thread
C: Else misplaced. - by Danger255 - Jan 27 2013, 02:39 PM
RE: C: Else misplaced. - by gOdzOOki - Apr 17 2013, 03:59 AM
RE: C: Else misplaced. - by Danger255 - Apr 21 2013, 03:45 AM
RE: C: Else misplaced. - by gOdzOOki - Apr 22 2013, 02:00 AM
RE: C: Else misplaced. - by Danger255 - Apr 24 2013, 04:07 PM
RE: C: Else misplaced. - by gOdzOOki - Apr 28 2013, 03:11 AM

Users browsing this thread: 1 Guest(s)