I'm in a rough situation, i'm currently re-reading all of my textbooks to assist me with this work, however I am really in a rough spot being time limited I really want to get somewhere from what I have (and fix what I have).
What I need to correct/add.
-I need case#3 to calculate properly, I'm not getting any calculation working.
I also cannot use a pow() function, so i used this, I cannot get it working so I will post it apart from the working code. Hopefully this is able to be incorporated.
counter = 1;
sum = 1;
while(counter <= exponent){
sum = sum*base;
counter++;
}
printf("The Sum is %d\n",sum);
-I need the code to "reshow" the menu instead of breaking/closing the code (only way to exit should be case#4 and nothing else.
-I used scanf, which i've found out is not allowed, and I wish to use getnum(), getch(), or any alternative to scanf, fscanf.
I'm very frustrated and overwhelmed with reading/doing this/time limitations/other classes. I need some assistance, as once I have these steps...hopefully I will be able to complete it. all of the following is code I have made thus far.
I'm VERY great-full if you are able to help me with this, as I have spent HOURS trying to do this on my own.
#include <stdio.h>
#include <conio.h>
#include <math.h>
int main(void)
{
int selection = 0;
double base = 1;
double exponent = 1;
int sum = 1;
printf("\nPower Menu:\n");
printf(" 1. Change Base\n");
printf(" 2. Change Exponent\n");
printf(" 3. Display base raised to exponent\n");
printf(" 4. Exit Program\n");
printf("Option:");
scanf("%d", &selection);
switch(selection)
{
case 1:
printf("Enter Base :");
printf("Base = %d\n", base, scanf("%d", &base));
break;
case 2:
printf("Enter Exponent :");
printf("Exponent = %d\n", exponent, scanf("%d", &exponent));
break;
case 3:
printf("The Sum is %d\n", pow(base,exponent));
break;
case 4:
printf("Exiting Program\n");
return 0;
default:
printf("Invalid Choice\n");
break;
}
return 0;
}