Function Problem

This is a discussion on Function Problem within the C++ Programming forums, part of the General Programming Boards category; Code: //Program Name : ngexpress.cpp// //Revision Date : 2002-10-11// //Explanation : Using variables and looping structures display a chart// // ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    72

    Function Problem

    Code:
    //Program Name : ngexpress.cpp//
    //Revision Date : 2002-10-11//
    //Explanation : 	Using variables and looping structures display a chart//
    //						The following assignment will demonstrate a program structure, code layout and use logic structures //
    //						The program will use data derived from a user and date acquired from the system at time of execution.//
    
    #include <iostream.h> 	//cout statement//
    #include <conio.h>     	//getch() and clrscr()//
    #include <string.h>		//strcpy()//
    #include <time.h>			//time function//
    #include <iomanip.h>		//decimal formatting//
    #include <math.h>
    
    								//function//
    
    double mycalc(double x, double& y)
    {
    
       y = (-2)*x^2 + 3*x + 1;
    
    }
    
               					//main part of program//
    int main(void)
    {
    	float start,end,yvalue;
    	time_t t=time(NULL);	//time function//
    
    								//Fowler Statement//
    	cout << setiosflags(ios::right);
    	cout << setw(79) << ctime(&t)<<endl;
    	cout << setw(79) << "Gavinn Niroopan"<<endl;
    	cout << setw(79) << "Mr. Slack"<<endl;
    	cout << setw(79) << "ICS 3MO-A"<<endl;
    	gotoxy(28,9);
    	cout << "Functions and Relations"<<endl;
    	gotoxy(28,10);
    	cout << "~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
    	cout << "Explanation: " <<endl;
    	cout << "\tUsing variables and looping structures display a chart,the"<<endl;
    	cout << "\tfollowing assignment will demonstrate a program structure, code"<<endl;
    	cout << "\tlayout and use logic structures. The program will use data derived"<<endl;
    	cout << "\tfrom a user and date acquired from the system at time of execution."<<endl;
    
    	getch();         		//pause screen//
       clrscr();				//clear screen//
    
       cout << ctime(&t) << endl;
    
       gotoxy(28,3);
    	cout << "Functions and Relations"<<endl;
    	gotoxy(28,4);
    	cout << "~~~~~~~~~~~~~~~~~~~~~~~"<<endl<<endl;
       cout << "What is the beginning reference in the range of  (-.2.5 to 3.5) - ";
       cin >>start;
       cout << "What is the ending reference in the range of  (-.2.5 to 3.5) - ";
       cin >> end;
    
       clrscr();
    
       cout << ctime(&t) << endl;
    
       gotoxy(28,3);
    	cout << "Functions and Relations"<<endl;
    	gotoxy(28,4);
    	cout << "~~~~~~~~~~~~~~~~~~~~~~~"<<endl<<endl;
    	cout << endl;
       cout <<setw(30)<< " Value of x " << setw(30) << " y = -2x^2 + 3x + 1 " << endl;
       cout <<setw(30)<< " ~~~~~~~~~~ " << setw(30) << " ~~~~~~~~~~~~~~~~~~ " << endl<<endl;
    
       for(start; start<=end; start = start + 0.5)
    
       {
       	mycalc(start,yvalue);
    
          cout << setiosflags(ios::fixed|ios:: right);
          cout << setprecision(1);
          cout << setw(30)<< start << setw(30) <<yvalue<<endl;
    
       }
    
    
    
       getch();
    
    
    
    }
    can someone tell me how to fix this, thanks. The error is:

    Illegal Use of Floating point, in and around function at top of program

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    72
    hmm now i get values of 0.0 for my "yvalue"

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    72
    nevermind, got it working properly now

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 10-29-2008, 07:33 AM
  2. wxWidgets link problem
    By cboard_member in forum C++ Programming
    Replies: 2
    Last Post: 02-11-2006, 02:36 PM
  3. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-30-2005, 12:21 AM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM
  5. Problem with function pointers
    By vNvNation in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2004, 07:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21