Computer Science Canada

Correcting C++ program

Author:  RichardVandebeek [ Wed Oct 28, 2009 8:28 am ]
Post subject:  Correcting C++ program

Hi i am new to C++ programming and i need help correcting all the problems i have in the following program.

/*
* This program reads a length in yards from
* the keyboard, converts the length to feet
* and inches, and writes the converted length to
* the display. It is assumed that the length is
* a nonnegative integer.
*

#include {stdlib.h}
#include {stdio.h}

int main()
printf( "Enter length " );
scanf( "%C", &yard );


foot = 3 * yrd;
inch = 36 * yrd;

printf( "\n%d yd =\n", &yrd );
printf( "%d ft\n", &foot );
printf( "%d in\n", &inch );


printf( "*** END OF PROGRAM ***" );

return ( 0 );

Any help would be much appreciated.

Author:  DemonWasp [ Wed Oct 28, 2009 9:10 am ]
Post subject:  RE:Correcting C++ program

This looks like a homework assignment to me, given how riddled that code is with obvious errors. If that's actually your code, the least you can do is try compiling it (probably after closing that comment at the top) and reporting the errors so we don't have to compile it ourselves.

Author:  Tony [ Wed Oct 28, 2009 11:08 am ]
Post subject:  Re: Correcting C++ program

also...
RichardVandebeek @ Wed Oct 28, 2009 8:28 am wrote:
stdlib.h
printf( "Enter length " );
scanf( "%C", &yard );

You seem to be using C, not C++.


: