/***************************************...
*
* Program name: Lab 10
* Author : Daniel J. Carr
* Date : December 10th, 2007
* Course/selection: CSC-110-003
* Program Description:
*
*
*
**************************************...
/************************** Compiler Directives **********************/
// libraries
#include %26lt;iostream%26gt;
#include %26lt;iomanip%26gt;
#include %26lt;cmath%26gt;
using namespace std;
/*********************** Global Data Declarations ********************/
/*************************** Function Prototype **********************/
void chop(float chipmunk,int%26amp; head,float%26amp; tail);
/*************************************...
*
* Function name: Main
* Author: Daniel J. Carr
* Date: December 10th, 2007
* Function Description:
*
* Pseudocode:
* Level 0
* -------
* Enter a float
* Chop it
* Output pieces
*
*
* Level 1
* -------
* Enter a float
* Display "Enter a floating point number----%26gt; "
* Input Chipmunk
* Chop it
* Call funtion chop to split chipmunk into head and tail
* Output Pieces
* Display "The whole number---%26gt; "%26amp; head %26amp; EOL
* Display "The Deciman number-%26gt; "%26amp; tail %26amp; EOL
*
**************************************...
int main()
{
//Varables
float chipmunk;
//arguements
int head;
float tail;
cout %26lt;%26lt; "Enter a floating point number----%26gt; " %26lt;%26lt; endl;
cin %26gt;%26gt; chipmunk;
//Call function chop
cout %26lt;%26lt; "The whole number----%26gt; "%26lt;%26lt; head %26lt;%26lt; endl;
cout %26lt;%26lt; "The Decimal number--%26gt; "%26lt;%26lt; tail %26lt;%26lt; endl;
//Indicate successful termination of program
return 0;
}
//End main
/*************************************...
*
* Function name: Chop
* Author: Daniel J. Carr
* Date: December 4th
* Function Description:
*
* Pseudocode:
* Level 0
* -------
* Chop it
*
* Level 1
* -------
* Chop it
* whole = int(number)
* Decimal =|number-whole|
*
**************************************...
void chop(float chipmunk,int%26amp; head,float%26amp; tail)
{
// Variables
// Arguements
head = chipmunk;
tail = fabs(chipmunk-head);
}
I guess ill go for another shot, c++ now im getting two warnings and I ingore them and it give me a werid answ
Problem is here:
cout %26lt;%26lt; "The whole number----%26gt; "%26lt;%26lt; head %26lt;%26lt; endl;
cout %26lt;%26lt; "The Decimal number--%26gt; "%26lt;%26lt; tail %26lt;%26lt; endl;
You are using head and tail before calling the function that initializes the variables. Here they would just contain garbage.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment