Home » Ask & Discuss » Board Exams - CBSE, ICSE, State Boards » Computer Science « Back to Discussion



Computer Science

Ayush's Avatar
Cool goIITian

Joined: 7 Sep 2008
Post: 91
30 Apr 2009 16:38:00 IST
0 People liked this
1
256 View Post
program for exponential
None

The program for the output can be written as

There are no errors in the program but it is saying divide-exception error and hence it failed.


Share this article on:

Comments (1)

RyuAmakusa's Avatar

Blazing goIITian

Joined: 21 Mar 2008
Posts: 776
5 May 2009 18:10:58 IST
1 people liked this

#include<iostream.h>
#include<conio.h>

//why did u have to give the  inside a class .....why not just a fun.

class abc
{ public:

// u r returning a float value right...

float facto(int num)
{ clrscr();

// though u store the value 1/fact in a float variable 1/fact will be int...if fact is int

float fact=1;
while(num)
{fact*=num;
--num;}
float i=1/fact;

// why print hear???....no prob though

cout<<i;

//......why did u return 0.....

return i;
}
};
void main()
{
abc o;
float sum=1;
int number=1;

//....when do u want to see the ans........

while(number<22)
{ sum+=o.facto(number);
++number;
}
cout<<sum;
}

// it will be better if u post the code not as an image




Quick Reply


Reply

Some HTML allowed.
Keep your comments above the belt or risk having them deleted.
Signup for a avatar to have your pictures show up by your comment
If Members see a thread that violates the Posting Rules, bring it to the attention of the Moderator Team
Free Sign Up!

Preparing for IIT-JEE ?

Arihant Revision Package for IIT JEE - Books, Practice Tests + Rank Predictor


@ INR 1,995/-

For Quick Info

Name

Mobile No.

Find Posts by Topics

Physics.

Topics

Mathematics.

Chemistry.

Biology

Parents

Board

Fun Zone

Sponsored Ads