Re: help with C program

  • From: "John Miller" <n1umj@xxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 19 Sep 2007 22:22:42 -0400

Well, I had 102 errors, with and with out what you said but, I'm eliminating the blank spaces now and the more I eliminate, the more errors go away when I try to compile. Does that make sense? I thought spaces were alright.

   Could I be doing something else in that process I'm not aware of?
It's not perfect yet, but I lost 2/3 of the errors in getting rid of blank spaces so far and I'm not done yet. ----- Original Message ----- From: "Littlefield, Tyler" <compgeek13@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Wednesday, September 19, 2007 9:55 PM
Subject: Re: help with C program


main needs int in front of it.
also need to return.
Thanks,
Tyler Littlefield.
Vertigo head coder
"My programs don't have bugs, just randomly added features."
msn: compgeek134@xxxxxxxxxxx
email: compgeek13@xxxxxxxxx
aim: st8amnd2005
skype: st8amnd127
----- Original Message ----- From: "John Miller" <n1umj@xxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Wednesday, September 19, 2007 7:04 PM
Subject: Re: help with C program


OK, I've been messing around with this since, well, early afternoon? and this is what I keep coming back to but it comes up with a bunch of errors I don't understand. I'm probalby goign to change little things up a bit once I figure out what I'm doing but maybe some one can give me a couple hints what's wrong here?

code is:
#include <stdio.h>

main ()

{

      int clock;      /* clock number */

      float gross;    /* gross pay */

      float hours;    /* hours worked */

      float wage;     /* hourly wage */

      /* Prompt for input values from the screen */

   printf("enter your employee number: ");

   scanf("%d", &clock);

   printf("employee number %d\n", clock);

printf("Enter number of worked hours: ");

scanf("%f", &hours);

printf("Enter the wage: ");

scanf("%f", &wage);

      /* calculate gross pay */

      gross = wage * hours;

      /* print out employee information to the screen */



printf("This employee worked %f hours with a per-hour basis of

%f.\n", hours, wage);

printf(" gross pay is %f.\n", gross);

}



end code

----- Original Message ----- From: "Delaunay Christophe" <christophe.delaunay@xxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Wednesday, September 19, 2007 11:23 AM
Subject: RE: help with C program


Hi John,

Hey, you're not so far. You've got it all indeed.

Here I report the code from so-called "shell with hints in place" and
you will notice that you really aren't so far from the solution.

Here it goes:
------------------ #include <stdio.h>

void main() /* This "void" is necessary in C since you must type
anything. The "void" keyword means "no value". In other words, you say
that the main() operation doesn't return any value. */
{
      /* Declare variables */
      int clock;      /* clock number */
      float gross;    /* gross pay */
      float hours;    /* hours worked */
      float wage;     /* hourly wage */

      /* Prompt for input values from the screen */

               /*... use printf and scanf here*/
printf("Enter number of worked hours: ");
scanf("%f", &hours);
printf("Enter the wage: ");
scanf("%f", &wage);

      /* calculate gross pay */
      gross = wage * hours;

      /* print out employee information to the screen */

              /*... now print out to the screen using printf (ie, print
the
value of the variables) */
printf("This employee worked %f hours with a per-hour basis of
%f.\n", hours, wage);
printf("Therefore, their gross pay is %f.\n", gross);
} /* end of main */
-----------------------------

However, maybe it is not the full solution to your problem since, as you
presented the problem, I can't figure out what the "clock" integer
variable is for.

My answer is only intended to give you some sample code which use the
printf() and scanf() function and which works. But, if you compile it as
is, you will get a warning "Unreferenced variable clock" since, as I
don't know what it is for, I never used it within my sample code.

HTH, Have a nice day. ChD

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of John Miller
Sent: mercredi 19 septembre 2007 16:27
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: help with C program

OK, I've done some looking and what I have is as bad a mess as I
thought. I have a shell with hints which I didn't bother with, and
another one with out hints I have been working with, I'll post both so
people can tell what I'm trying to do and how. I know there are more
than 1 way to do some of this but we were strictly told we lose a lot of
credit getting ahead of ourselves. Personally, I think there are easier
ways to do some of this but can't afford to lose any more credit than my
lack of knowledge will cost me already. I'll post what I'm working on
first, please to easy on the complete novis.
I know this is a mess, I was doing things completely wrong, tried to fix
it and this is the result and I think it's still wrong but better than
it was, I hope.

/***********************************************************************
*/

/* */

/* HOMEWORK: 1 - Chapter 4 */

/* */

/* Name: John Miller */

/* */

/* Class: C Programming, Cybercourse, */

/* */

/* Date: 9/17/20xx */

/* */

/* Description: Program which determines gross pay and outputs */

/* a formatted answer. */

/* */

/***********************************************************************
*/



#include <stdio.h>



main()

{

/* Declare variables */

      int a = clock;      /* clock number */

      float b = gross pay;    /* gross pay */

      float c =;    /* hours worked */

      float d = 10.0;     /* hourly wage */

/* Prompt for input values from the screen */

 printf("Enter hours:");

scanf("%d", &b);

b = c * d;

printf ( "wage is %d \n" ) ;

/* calculate gross pay */



/* print out employee information to the screen */

}





now the shell with hints in place, sorry, I knwo the above is probably
beyond horrible.




#include <stdio.h>

main()
{
      /* Declare variables */
      int clock;      /* clock number */
      float gross;    /* gross pay */
      float hours;    /* hours worked */
      float wage;     /* hourly wage */

      /* Prompt for input values from the screen */

               ... use printf and scanf here

      /* calculate gross pay */
      gross = wage * hours;

      /* print out employee information to the screen */

              ... now print out to the screen using printf (ie, print
the
value of the variables)

}
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: