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