Ask your own question, for FREE!
Computer Science 9 Online
OpenStudy (lgbasallote):

IMPORTANT!! please tell me what i did wrong in my code..it's showing error (im using bloodshed dev c++)

OpenStudy (lgbasallote):

#include<stdio.h> #include<conio.h> main() { int a, b, c, d, e, f, g, h, i, j, k, l, m, n ,o, p, q, r, s, t, u; start: printf("What do you want to do? \n To add, press 1. \n To subtract, press 2. \n To multiply, press 3. \n To divide, press 4. \n To find the modulus, press 5. \t To do exponent press 6 \t "); scanf("%d", &a); if(a==1) { system("cls"); printf("Enter 1st number: "); scanf("%d", &b); printf("Enter 2nd number: "); scanf("%d",&c); d = b + c; printf("The sum of %d + %d = %d",b, c, d); printf("\n\nDo you want to restart? If yes, press 1. "); scanf("%d", &q); if (q==1) {system("cls"); goto start;} else {getch();} } else if (a==2) { system("cls"); printf("Enter 1st number: "); scanf("%d", &f); printf("Enter 2nd number: "); scanf("%d", &e); g = f - e; printf("The difference of %d - %d = %d", f, e, g); printf("\n\nDo you want to restart? If yes, press 1. "); scanf("%d", &q); if (q==1) {system("cls"); goto start;} else {getch();} } else if (a==3) { system("cls"); printf("Enter 1st number: "); scanf("%d", &h); printf("Enter 2nd number: "); scanf("%d", &i); j = h * i; printf("The product of %d x %d = %d", h, i, j); printf("\n\nDo you want to restart? If yes, press 1. "); scanf("%d", &q); if (q==1) {system("cls"); goto start;} else {getch();} } else if (a==4) { system("cls"); printf("Enter 1st number: "); scanf("%d", &k); printf("Enter 2nd number: "); scanf("%d", &l); m = k / l; printf("The quotient of %d / %d = %d", k,l,m); printf("\n\nDo you want to restart? If yes, press 1. "); scanf("%d", &q); if (q==1) {system("cls"); goto start;} else {getch();} } else if (a==5) { system("cls"); printf("Enter 1st number: "); scanf("%d", &n); printf("Enter 2nd number: "); scanf("%d", &o); p = n%o; printf("The modulus of %d / %d = %d", n, o, p); printf("\n\nDo you want to restart? If yes, press 1. "); scanf("%d", &q); if (q==1) {system("cls"); goto start;} else {getch();} } else if (a==6) { printf("Enter base: "); scanf("%d", &r); printf("Enter exponent: "); scanf("%d", &s); u=1; t=r; start: if (s>u) { t = t*r u = u + 1 goto start } printf("%d ^ %d = %d" ,r, s, t); printf("\n\nDo you want to restart? If yes, press 1. "); scanf("%d", &q); if (q==1) {system("cls"); goto start;} else {getch();} } else { system("cls"); goto start; } getch(); }

OpenStudy (rsmith6559):

Very possibly, it's complaining about the use of goto. You're using it syntactically correctly, but it's use is frowned upon for the past ~20 years. It may also be complaining about main() not be declared without a return type: void main() { }

OpenStudy (lgbasallote):

i dont know about that...but the first error was about system("cls") do you see anything wrong with it?

OpenStudy (rsmith6559):

That is a DOS command.

OpenStudy (rsmith6559):

system is defined in stdlib.h, which you haven't included.

OpenStudy (lgbasallote):

so i should put #include<stdlib.h>?

OpenStudy (lgbasallote):

it worked thanks

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!