•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 397,816 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,575 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 405 | Replies: 1
![]() |
Hey guys, this is a calculator program.
I keep getting 0s for my answers... is there something wrong with the logic in this function:
main()
function
I keep getting 0s for my answers... is there something wrong with the logic in this function:
main()
cin >> choice;
while ( choice != 'q' && choice != 'Q' ) {
cout << "For first fraction\n";
getFract(choice, 1, num1, den1);
cout << "For second fraction\n";
getFract(choice, 2, num2, den2);function
c++ Syntax (Toggle Plain Text)
void getFract(char op, int fractNo, int & num, int & den) { cout << " Enter the numerator: "; cin >> num; if ( op == '/' && fractNo == 2 && num == 0 ) { cout << "\nTo divide, the second fraction must be nonzero\n"; while ( num == 0 ) { cout << "\nEnter a nonzero number for the numerator: "; cin >> num; } // endwhile } // endif cout << " Enter the denominator: "; cin >> den; if ( den = 0 ) { cout << "The denominator must be nonzero\n"; while ( den = 0 ) { cout << "\nEnter the denominator: "; cin >> den; } // endwhile } // endif }
Last edited by Duki : May 2nd, 2007 at 10:32 am.
It is practically impossible to teach good programming style to students that have had prior exposure to Basic; as potential programmers they are mentally mutilated beyond hope of regeneration.
-Edsger Dijkstra
-Edsger Dijkstra
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
Similar Threads
- Pages needing more explicit refreshes than usual.. (DaniWeb Community Feedback)
- needing C++ tutorial (C++)
- Any recommendations on good Flash books? (Graphics and Multimedia)
- Needing help desperately (Windows NT / 2000 / XP / 2003)
- Newbee needing games for site (Community Introductions)
- Bitwise operators (C)
- Novell (Novell)
Other Threads in the C++ Forum
- Previous Thread: C enum.....
- Next Thread: functions in header files



Linear Mode