Find us On Facebook

Thursday, April 7, 2011

write a program to print a table of values of the function

//y=e raise to -x
//for x varying from 0 to 10 in steps of 0.1. the table should appear as follows.
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
#include <math.h>

class exponent
{
float i,j;
public:
exponent()
{i=0;j=0.0;}
void display(void);
};

void exponent :: display(void)
{
double sum;
    cout<<"\n\n\t\t\tTABLE FOR Y = EXP[-X]\n";
    for(int a=0;a<40;a++)
        cout<<"--";
    cout<<"\n";
    for(int c=0,b=0.0;c<10;b++,c++)
    {
        if(b==0.0)
        cout<<setw(c+5)<<"X";
        else
        cout<<setw(c+3)<<b;
    }
    cout<<endl;
    for(int d=0;d<40;d++)
         cout<<"==";
    cout<<endl;
c=0;
    while(i<10)
    {
        while(c<10)
        {
            sum=1/pow(i,j);
            if(c==0)
               cout<<setw(5)<<i;
            else
               cout<<setw(3)<<sum;
            if(c>10)
            break;
        }
    cout<<endl;
    }
}

void main()
{
clrscr();
exponent o1;
o1.display();
getch();
}

0 comments:

Post a Comment

Programms

C,C++,VB, PL/SQL EBOOK SEARCH ENGINE