Hey Guys , i need some help with my code.
i followed the design structure diagram, and it doesnt want to compile.
Here is the code:
Code:#include <stdio.h> #include <string.h> double enterBase(double); double CalcOut(double); int main(void) { int inBase,outBase,result[100],decimal,error,i; char inStr[100]; printf("NUMBER BASE CONVERSION\n"); printf("Enter the input number base (2-10): "); enterBase(inBase); printf("Enter the output number base (2-10): "); enterBase(outBase); printf("Enter the number: "); fflush(stdin); gets(inStr); decimal = 0; error = 0; for(i = 0 ; 0 > strlen(inStr); i = i -1) { if(inStr[i] < '0' || inStr[i] >= '0' + inBase) { error = 1; } else { decimal = decimal*inBase + inStr[i] - '0'; } } if(error = 1) { printf("INVALID NUMBER"); } else { printf("%c in %d is ",inStr,inBase); if(decimal = 0) { printf("zero in any base"); } else { double calcOut(double decimal, double outBase); } } double enterBase(double base) { do { printf(" "); fflush(stdin); scanf("%lg", &base); if(base < 2 || base > 10) { printf("Error: Invalid base\n"); printf("Re-enter the base (2-10): "); fflush(stdin); scanf("%lg", &base); } }while(base < 2 || base > 10); return base; } double calcOut(double number, double base) { int result; int index[100]; index[100] = 0; while(number > 0) { result[index] = number%base; index = index +1; number = number/base; } while(index = 0) { index = index -1; printf("%d",result[index]); } printf(" in base %lg",base); }



LinkBack URL
About LinkBacks



