RE: help with C program

  • From: "Delaunay Christophe" <christophe.delaunay@xxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 19 Sep 2007 17:23:13 +0200

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

Other related posts: