Hello Daniweb! I'm a beginner and C, and trying to make a program that asks a question in the main and takes an input from the user which jumps to the appropriate function. Here is the source.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void cm(){
float a;
double b;
printf("Enter a number in Inches to be converted to CM:");
scanf("%f", &a);
b = a * 2.54;
printf("%f", b);
}
int main()
{
float inch, restart;
do {
printf("Enter 1 to convert inches to cm, anything else to quit");
scanf("%f", &cm);
if ( inch == 1 )
{
cm();
}
else
{
system("exit");
}
printf("Press 1 to restart, anything else to quit");
scanf("%f", restart);}
while (restart == 1);
}
It compiles, but doesn't give the results I need, instead it gives me one warning,
Warning 1 warning C4700: uninitialized local variable 'restart' used.
Can anyone help?