fork download
  1. #include <stdio.h>
  2. int square(int n)
  3. {
  4. return n*n;
  5. }
  6. int cube(int n)
  7. {
  8. return n*n*n;
  9. }
  10. int main()
  11. {
  12. int intValue,menuSelect,result;
  13. printf("Enter the number:");
  14. scanf("%d",&intValue);
  15. while(n>0)
  16. {
  17. printf("1.square\n2.cube");
  18. printf("\n Enter the choice:");
  19. scanf("%d",&menuSelect);
  20. switch (menuSelect)
  21. {
  22. case 1:
  23. result=square(intValue);
  24. printf("The square of %d is:%d",n,result);
  25. break;
  26. case 2:
  27. result=cube(intValue);
  28. printf("The square of %d is:%d",n,result);
  29. break;
  30. default:
  31. printf("Your choice is invalid");
  32. }
  33. printf("\nEnter the number:");
  34. scanf("%d",&intValue);
  35. }
  36. return 0;
  37. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
2
-2
3
4
-1
compilation info
prog.c: In function ‘main’:
prog.c:15:8: error: ‘n’ undeclared (first use in this function)
  while(n>0)
        ^
prog.c:15:8: note: each undeclared identifier is reported only once for each function it appears in
stdout
Standard output is empty