How about
a) Indentation.
Code:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
float total, var1;
int menu, menu2;
void defaultdata(void){}
main()
{
defaultdata();
menu = 0;
while (menu != 3) {
printf("1. Change variables\n");
printf("2. Run program\n");
printf("3. Exit program\n");
printf("Enter option. ");
scanf("%d", &menu);
switch (menu) {
case 1:
{
system("cls");
printf("1. variable1 %f\n", var1);
printf("2. variable 2\n");
printf("3. variable 3\n");
printf("4. variable 4\n");
printf("5. variable 5\n");
printf("6. Reset all to default\n");
printf("7. Return to Main Menu\n\n");
printf("Enter option. ");
scanf("%d", &menu2);
switch (menu2) {
case 1:
{
printf("Enter variable 1:");
scanf("%f", &var1);
total = 300 + (120 * var1);
break;
}
case 2:
{
}
case 3:
{
}
case 4:
{
}
case 5:
{
}
case 6:
{
defaultdata();
break;
}
case 7:
{
menu = 1;
break;
}
default:
{
printf("ERROR invalid");
}
}
}
}
}
}
Good indentation goes a long way to helping you figure out problems yourself, as well as attracting the attention of helpers when you're stuck.
b) Using a decent compiler.
Code:
$ gcc foo.c
foo.c: In function ‘main’:
foo.c:24: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘double’
foo.c:38: warning: format ‘%d’ expects type ‘int *’, but argument 2 has type ‘float *’
Your illegal format conversions are probably doing something you don't want.
New result
Code:
$ ./a.out
1. Change variables
2. Run program
3. Exit program
Enter option. 1
sh: cls: not found
1. variable1 0.000000
2. variable 2
3. variable 3
4. variable 4
5. variable 5
6. Reset all to default
7. Return to Main Menu
Enter option. 1
Enter variable 1:33
1. Change variables
2. Run program
3. Exit program
Enter option. 3