473,396 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Please Find out the logical error

Expand|Select|Wrap|Line Numbers
  1. #include<iostream.h>
  2. #include<conio.h>
  3. class factorial
  4. {
  5. int no,fact;
  6. public:
  7. void getdata();
  8. void calculate();
  9. void display();
  10. };
  11. void factorial::getdata()
  12. {
  13. cout<<"Enter a no"<<endl;
  14. cin>>no;
  15. }
  16. void factorial::calculate()
  17. {
  18. int fact=1;
  19. for(int i=1;i<=no;i++)
  20. {
  21. fact=fact*i;
  22. }}
  23. void factorial::display()
  24. {
  25. cout<<"Factorial of entered number is "<<fact;
  26. }
  27. void main()
  28. {
  29. clrscr();
  30. factorial f;
  31. f.getdata();
  32. f.calculate();
  33. f.display();
  34. getch();
  35. }
Jul 20 '13 #1
1 1407
Rabbit
12,516 Expert Mod 8TB
You have two variables named fact. The local one overrides the class one.
Jul 20 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: muser | last post by:
Can anyone run this program through their compiler or if they can see a logical error please point it out. I have my tutor working on it at the moment but I would rather a less ambigious response...
3
by: Denny Schierz | last post by:
hi, i have a logical error in my css file, but i don't no where. have a look: http://lippelt-back.com/fileadmin/template/css/new-body.css i comment this lines:
4
by: GRoll21 | last post by:
The problem starts during my while loop. It checks to see if they hit x or X. If they did, then that means the user wants to exit. Then should go on and hit the return statement. It just quits....
19
by: ashmangat | last post by:
Hi! now on the chapter "string-class" My assignment is below Word Counter: Write a function that accepts a pointer to a C-String as an argument and returns the number of words contained in the...
6
by: pamela fluente | last post by:
Hi, please find below a very simple code snippet which is giving me the following error: System.Runtime.Serialization.SerializationException was unhandled Message="The constructor to deserialize...
3
by: saundra | last post by:
Here is my error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/truthat/public_html/verukasalt/admin/main.php(1) : eval()'d code(1) : eval()'d code(1)...
2
by: gnanapoongothai | last post by:
what is logical error found in the code below .Could any find. If( (x!=3) || (x!=4) ) printf("something"); else printf("something") thanks in advance for your answers.
3
by: anchitgood | last post by:
I have tried a lot but unable to correct just 1 logical error in the following code. This error is in the for loop, when fine and minutes are printed as the garbage values. Please check it out: ...
8
by: neovantage | last post by:
Hey all, Website page is not working properly in IE6 and IE7 but working normal in firefox. Can somebody tell me how i can fixed that problem. Here is the url of the page http://www.ragehockey.biz/...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.