I'm having trouble writing exponents. I know initially how you're supposed to define a variable and use the pow() func. but my scenario is a bit different and I need to compile and email this by tonight
x = pow(4,6);
something like this, where it's showing 4 to the 6th power. as i said before, my case is a little worse.
when I (try to) compile it, it says "invalid operands to binary ^" then there's a whole LIST of all the variables I put in. "invalid suffix "z" on integer constant
"invalid suffix "x" onasaifasfjaklsjgkasjg.. and so on.
Code:#include <stdio.h> #include <math.h> main() { int p1; int p2; int p3; int p4; int p5; printf("Directions:\n"); printf("Simplify the monomials.\n"); printf("Write out exponents using the "^" key.\n"); printf("12p^5 = 12 times p to the 5th power\n"); /* this is a thing I did for my math teacher for extra credit basically*/ /*--------------------------------------------------------*/ printf("54x^3z, 36z^5x\n"); scanf("%d", &p1); if (p1 != 18z) { printf("Incorrect\n"); } else { printf("Correct\n"); } system("pause"); /*-----------------------------------------------------*/ printf("74ac, 116b^3a\n"); scanf("%d", &p2); if (p2 != 2a) { printf("Incorrect\n\a"); } else { printf("Correct\n"); } system("pause"); /*------------------------------------------------------*/ printf("2xyz^4t^3, 14pz^2y^5\n"); scanf("%d", &p3); if (p3 != 2z^2y) { printf("Incorrect\n"); } else { printf("Correct\n");} system("pause"); /*---------------------------------------------------------*/ printf("6y^4, 12y^2\n"); scanf("%d", &p4); if (p4 != 6y^2) { printf("incorrect\n\a"); } else { printf("correct\n"); } system("pause"); /*-------------------------------------------------*/ printf("8mp^3, 20x^7p^5\n"); scanf("%d", &p5); if (p5 != 4p^3) { printf("Incorrect\a\n"); } else { printf("Correct\n"); } printf("Thank you for playing!\n"); system("pause"); return 0; }



LinkBack URL
About LinkBacks



