-
Exponent and C4550
Hey guys. I am new to C programming and I am trying to compile and run an exponent program my instructor posted for us but it is giving me an error saying:
Warning c4550: expression evaluates to a function which is missing an argument list.
My instructor is not really helpful with why this is happening (she doesn't seem to find anything wrong with the code). From what I could gather there is some issue with the math but idk. It is supposed to prompt for the number and the exponent to raise it to, then calculate and output the result.
Code:
#include <stdio.h>
int main()
{
int base, exp;
long long int value=1;
printf("Enter the base number and exponent: ");
scanf("%d%d", &base, &exp);
while (exp!=0);
{
value*=base; /* value = value*base; */
--exp;
}
printf;
}
-
change the name of exp, also your printf statement should be
printf("%d", value);
-
Alright. It runs now but I have tried all different ways of entering the two numbers but the program never actually does the math.
Code:
#include <stdio.h>
int main()
{
int base, power;
long long int value=1;
printf("Enter the base number and exponent: ");
scanf("%d%d", &base, &power);
while (power!=0);
{
value*=base; /* value = value*base; */
--power;
}
printf("%d", value);
}
-
you have a semi colon after your while loop, while loop never executes
while(power!=0) then you have this semicolon, can't do that, delete it and you're good
-
1 Attachment(s)
Attachment 13258
I changed it and it still isn't working :/ I tried 2 space 2; 2 enter 2; 2 comma 2; 2 semicolon 2
Nothing works.
-
Code:
#include <stdio.h>
int main()
{
int base, cat;
long int value=1;
printf("Enter the base number and exponent: ");
scanf("%d", &base);
scanf("%d", &cat);
while (cat!=0)
{
value*=base; /* value = value*base; */
cat--;
}
printf("%d", value);
}
use your scanf in two different lines
-
> scanf("%d%d", &base, &power);
You need to separate your input with spaces, not commas.
If you want a comma separator on input, then your format string needs to contain a comma.
-
Attachment 13258
I changed it and it still isn't working :/ I tried 2 space 2; 2 enter 2; 2 comma 2; 2 semicolon 2
Nothing works.
-
I know for a fact it works, my semicolon comments were from your actual code, you would have to enter it in as 2 2 from what you typed as Salem said. You need to just break them into two different scanf, honestly scanf isn't a good function to use for many reasons. Just do as I showed you
-
Ahhhh I actually didn't see your last two posts until just now I checked it and what you posted works great. It makes a lot of sense to put the scanf on separate lines actually. Thank you for the help!!