// code says misplaced else can some tell me why and if possible make the correction?
#include<stdio.h>
#include<conio.h>
char oper;
int num[2];
int ans;
main()
{
clrscr();
printf("Num:");
scanf("%d",&num[0]);
printf("+");
scanf("%c",&oper);
{
if(oper=='+')
{
printf("+");
}
{
printf("Num:");
scanf("%d",&num[1]);
}
ans = num[0] + num[1] ;
printf("%d",ans);
}
{
else if(oper=='-')
{
printf("+");
}
{
printf("Num:");
scanf("%d",&num[1]);
}
ans = num[0] - num[1] ;
printf("%d",ans);
}
getch();
}
hayate98 0 Newbie Poster
hayate98 0 Newbie Poster
sepp2k 378 Practically a Master Poster
hayate98 0 Newbie Poster
hayate98 0 Newbie Poster
Moschops 683 Practically a Master Poster Featured Poster
hayate98 0 Newbie Poster
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster
hayate98 0 Newbie Poster
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.