when I run my program in GCC ,there are some problem apperes to me ,,I need help to make it run !!Plz
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
// Declare a few variables
char InputString[32], type;
int NumValue, sum=0, Length, result;
int main() //main function
{
printf("Type in a number:");
if(!gets(InputString))
printf("You did not enter any value:\n");
Length = strlen(InputString);
if( (result = testnumber())==0 )
{
printf("That is an invalid number!"); // prints That is an invalid number!
exit(0);
}
Asktbase(); //call function Asktbase
// printf("value of type= %c" , type );
if( (type=='f') && (InputString[0]==48))
{
binary_decimal() ;
exit(0);
}
if(type=='f')
{
printf("Is this number decimal (d) or binary (b)?");
scanf("%c",&type);
if(type=='d') decimal_binary();
if(type=='b') binary_decimal();
}
else
{
if( (result = testnumber())==0)
{
printf("That is an invalid number!");
}
Length = strlen(InputString); //strlen: Find length of string
IsDecimal();
if(type=='d')
{
if(atoi(InputString)<=255 ) decimal_binary(); //atoi: Convert ASCII string to integer
else
{
printf("That is an invalid number!");
exit(0);
}
}
else binary_decimal();
}
}
binary_decimal() //function to convert binary to decimal number
{
int i, p, a;
for(i=1; i<=Length; i++)
{
if(InputString[Length-i]==49) NumValue=1;
else NumValue=0;
if(NumValue==1)
{
p=i-1;
a=pow(2,p);
sum=sum+a;
}
}
printf("Converting binary to decimal. Answer is: %d \n", sum); // print number binary to decimal
}
decimal_binary() //function to convert decimal to binary number
{
int dec,i=1,rem,res=0;
dec = atoi(InputString); // //atoi: Convert ASCII string to integer
while(dec>0)
{
rem=dec%2;
dec=dec/2;
res=res+(i * rem);
i=i*10;
}
printf("Converting decimal to binary. Answer is: %8.8d",res); //print number decimal to binary
}
int testnumber()
{
int i ;
for(i = 1 ; i <= Length ; i++)
{
if(isdigit(InputString[Length-i])) //isdigit - test for a decimal digit
return 1 ;
else return 0 ;
}
}
IsDecimal()
{
int i;
for(i = 1 ; i <= Length ; i++)
{
//ASCII code 50 is equal to Two,51 equal to three, 52 equal to four, 53 equal to five, 54 equal to six, 55 equal to seven, 56 equal to eight, 57 equal to nine
if( ( InputString[Length-i] ==50) || ( InputString[Length-i] ==51)||( InputString[Length-i] ==52)||( InputString[Length-i] ==53)
||( InputString[Length-i] ==54)||( InputString[Length-i] ==55)||( InputString[Length-i] ==56)||( InputString[Length-i] ==57))
type = 'd' ;
}
if((InputString[0] ==48) && (type = 'd'))
{
printf("That is an invalid number!");
exit(0);
}
}
testbase()
{
int i;
for(i = 1 ; i <= Length ; i++)
{
if( ( InputString[Length-i] !=49) || (InputString[Length-i]!=48))
type = 'd' ;
}
}
Asktbase()
{
int i;
for(i = 1 ; i <= Length ; i++)
{
if( ( InputString[Length-i] ==49) || (InputString[Length-i] ==48) ) //ASCII code 48 is equal to zero and 49 equal to 1
{
type='f' ;
}
else
{
type='a' ;
Length = i - 1 ;
}
}
}
-------------
my error
assign1.c: In function `int main()':
assign1.c:19: error: `testnumber' was not declared in this scope
assign1.c:25: error: `Asktbase' was not declared in this scope
assign1.c:30: error: `binary_decimal' was not declared in this scope
assign1.c:38: error: `decimal_binary' was not declared in this scope
assign1.c:39: error: `binary_decimal' was not declared in this scope
assign1.c:43: error: `testnumber' was not declared in this scope
assign1.c:49: error: `IsDecimal' was not declared in this scope
assign1.c:53: error: `decimal_binary' was not declared in this scope
assign1.c:60: error: `binary_decimal' was not declared in this scope
assign1.c: At global scope:
assign1.c:65: error: ISO C++ forbids declaration of `binary_decimal' with no type
assign1.c: In function `int binary_decimal()':
assign1.c:74: warning: converting to `int' from `double'
assign1.c: At global scope:
assign1.c:82: error: ISO C++ forbids declaration of `decimal_binary' with no type
assign1.c: In function `int testnumber()':
assign1.c:100: error: `isdigit' was not declared in this scope
assign1.c: At global scope:
assign1.c:107: error: ISO C++ forbids declaration of `IsDecimal' with no type
assign1.c:127: error: ISO C++ forbids declaration of `testbase' with no type
assign1.c:138: error: ISO C++ forbids declaration of `Asktbase' with no type
>Exit code: 1