1. If you're going to be using a gcc based compiler, then figure out how to enable as many warnings as possible. This compiler in particular is capable of telling you when you've messed up with printf() and scanf()
2. Learn to format code. I don't care what you do so long as you're consistent. Any consistent approach will easily tell you that you missed a brace (see comments below)
My suggestion would be fix the missing brace, then set up the compiler so it produces the list of warnings shown below. You should be able to add the extra command line options "-W -Wall -ansi -pedantic -O2" to the compiler settings for your project.
Here's your code, reformatted
Code:
#include <stdio.h>
int main(void)
{
char name[30];
int pay = 0; /*selected from case group by alph corispondant # */
int hours = 0; /*user input with if elas statments */
int hlhrs = 0; /*user input in conjunction with the if eals statments */
int ot = 0; /*mathmatical calculation with in the if eals than statments */
int othol = 0;
int check = 0; /*total amount of pay for the week */
printf("What is your Name?");
scanf("%s", name);
printf("Good Day to you %s.");
printf("Please chose one of the following choses so we know the amount of your hourly pay.\n");
printf("1 : $10.00 an hour.");
printf("2 : $20.00 an hour.");
printf("3 : $30.00 an hour.");
printf("4 : $50.00 an hour.");
scanf("%d", pay);
switch (pay) {
case 1:
pay = 10;
break;
case 2:
pay = 20;
break;
case 3:
pay = 30;
break;
case 4:
pay = 50;
break;
default:
pay = 10;
break;
} /*!! Missing */
printf("So How many Hours did you work?");
scanf("%d", hours);
if (hours <= 40); /*!! what's this ; doing here? */
{
check = pay * hours;
printf("Your pay this week will be $", check);
}
if (hours > 40); /*!! what's this ; doing here? */
{
printf("How many Holiday and Sunday Hours did you have? IF any!");
scanf("%d", hlhrs);
printf("How many Overtime hours did you work? If any!");
scanf("%d", ot);
} /* end if eals */ /*!! what 'else' are you on about? */
check = ((hlhrs * 2) + (ot * 1.5) + (hours - (hlhrs + ot)));
printf("Your pay this week will be $", check);
}
And here are the error messages you should be seeing. Pay close attention to every single one of them.
Code:
$ gcc -W -Wall -ansi -pedantic -O2 foo.c
foo.c: In function ‘main’:
foo.c:14: warning: too few arguments for format
foo.c:20: warning: format ‘%d’ expects type ‘int *’, but argument 2 has type ‘int’
foo.c:39: warning: format ‘%d’ expects type ‘int *’, but argument 2 has type ‘int’
foo.c:41: warning: empty body in an if-statement
foo.c:44: warning: too many arguments for format
foo.c:46: warning: empty body in an if-statement
foo.c:49: warning: format ‘%d’ expects type ‘int *’, but argument 2 has type ‘int’
foo.c:52: warning: format ‘%d’ expects type ‘int *’, but argument 2 has type ‘int’
foo.c:56: warning: too many arguments for format
foo.c:9: warning: unused variable ‘othol’
foo.c:57: warning: control reaches end of non-void function