Hey,
I'm new to programming in C, and i have been having a problem with a simple program that i recently coded. Xcode is giving me parse error message for an "if" line that i can almost swear is right. Check it out.
#include<stdio.h>
#include<math.h>
int a, b, d, e, f ;
char c;
int main (void)
{
printf("enter a number");
scanf("%i",&a);
printf("enter another number");
scanf("%i",&b);
Printf("this is the menu");
Printf("\n 1. *");
printf("\n 2. +");
printf("\n 3. -");
printf("\n 4. /");
printf("\n 5. %");
printf("\n 6. ^");
scanf("%char",&c);
if(c==*){
d=a*b;
}
if(c==+){
d=a+b;}
the error message is "parse error before ")" token. I am not sure what the error is , but i've tried eveything i could, can someone help me out? i have an exam soon and i want to be up to mark.
Thanks..
I'm new to programming in C, and i have been having a problem with a simple program that i recently coded. Xcode is giving me parse error message for an "if" line that i can almost swear is right. Check it out.
#include<stdio.h>
#include<math.h>
int a, b, d, e, f ;
char c;
int main (void)
{
printf("enter a number");
scanf("%i",&a);
printf("enter another number");
scanf("%i",&b);
Printf("this is the menu");
Printf("\n 1. *");
printf("\n 2. +");
printf("\n 3. -");
printf("\n 4. /");
printf("\n 5. %");
printf("\n 6. ^");
scanf("%char",&c);
if(c==*){
d=a*b;
}
if(c==+){
d=a+b;}
the error message is "parse error before ")" token. I am not sure what the error is , but i've tried eveything i could, can someone help me out? i have an exam soon and i want to be up to mark.
Thanks..