Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › C++ Fraction Calculator
New Posts  All Forums:Forum Nav:

C++ Fraction Calculator

post #1 of 2
Thread Starter 
Hi, guys. I have a homework assignment on C++ to create a simple fraction calculator that will take 2 fractions and will add, subtract, multiply or divide them as per the user's request. I decided to add a function that will also reduce the fractions. For example if the result of adding the fractions was 6/24. It would reduce it to 1/4.

I can not find where or how I went wrong but I am getting a runtime error #3. I am using Visual Studio 2010 Pro. Any help or pointers to where I need to look or correct is greatly appreciated.

Thanks!

*edit*

Never mind. Figured it out thanks!

I had 2 variables that I had declared but did not initialize.
Edited by eroz - 9/24/12 at 1:27pm
First Build
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 g0 @ 3.36ghz Abit IP35 8800GTS 640mb corsair 2x1gb XMS2 + 2x2gb XMS2 
Hard DriveOSMonitorKeyboard
Seagate Barracuda 750gb Windows 7 Acer 19" wide Logitech Wave 
PowerCaseMouseMouse Pad
Antec Neopower 650w NXZT Tempest Logitech USB FCBarcelona 
  hide details  
Reply
First Build
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 g0 @ 3.36ghz Abit IP35 8800GTS 640mb corsair 2x1gb XMS2 + 2x2gb XMS2 
Hard DriveOSMonitorKeyboard
Seagate Barracuda 750gb Windows 7 Acer 19" wide Logitech Wave 
PowerCaseMouseMouse Pad
Antec Neopower 650w NXZT Tempest Logitech USB FCBarcelona 
  hide details  
Reply
post #2 of 2
Your runtime error could be any number of things. Can you post the code? And give the line number the error is occurring on.

Without seeing any of your code, my best guess is that you're dividing an integer by zero.

EDIT: Nevermind I see you solved the issue.
Foldatron
(17 items)
 
Mat
(10 items)
 
Work iMac
(9 items)
 
CPUMotherboardGraphicsGraphics
i7 950 EVGA x58 3-way SLI EVGA GTX 660ti GTX 275 
RAMHard DriveHard DriveHard Drive
3x2GB Corsair Dominator DDR3-1600 80GB Intel X25-M SSD 2TB WD Black 150GB WD Raptor 
Hard DriveOSMonitorKeyboard
2x 150GB WD V-raptor in RAID0 Win7 Home 64-bit OEM 55" LED 120hz 1080p Vizio MS Natural Ergonomic Keyboard 4000 
PowerCase
750W PC P&C Silencer CoolerMaster 690 
CPUGraphicsRAMHard Drive
Intel Core i5 2500S AMD 6770M 8GB (2x4GB) at 1333Mhz 1TB, 7200 rpm 
Optical DriveOSMonitorKeyboard
LG 8X Dual-Layer "SuperDrive" OS X Lion 27" iMac screen Mac wireless keyboard 
Mouse
Mac wireless mouse 
CPUGraphicsRAMHard Drive
i7-2600K AMD 6970M 1GB 16GB PC3-10600 DDR3 1TB 7200rpm 
Hard DriveOptical DriveOSMonitor
256GB SSD 8x DL "SuperDrive" OS X 10.7 Lion 27" 2560x1440 iMac display 
Monitor
27" Apple thunderbolt display 
  hide details  
Reply
Foldatron
(17 items)
 
Mat
(10 items)
 
Work iMac
(9 items)
 
CPUMotherboardGraphicsGraphics
i7 950 EVGA x58 3-way SLI EVGA GTX 660ti GTX 275 
RAMHard DriveHard DriveHard Drive
3x2GB Corsair Dominator DDR3-1600 80GB Intel X25-M SSD 2TB WD Black 150GB WD Raptor 
Hard DriveOSMonitorKeyboard
2x 150GB WD V-raptor in RAID0 Win7 Home 64-bit OEM 55" LED 120hz 1080p Vizio MS Natural Ergonomic Keyboard 4000 
PowerCase
750W PC P&C Silencer CoolerMaster 690 
CPUGraphicsRAMHard Drive
Intel Core i5 2500S AMD 6770M 8GB (2x4GB) at 1333Mhz 1TB, 7200 rpm 
Optical DriveOSMonitorKeyboard
LG 8X Dual-Layer "SuperDrive" OS X Lion 27" iMac screen Mac wireless keyboard 
Mouse
Mac wireless mouse 
CPUGraphicsRAMHard Drive
i7-2600K AMD 6970M 1GB 16GB PC3-10600 DDR3 1TB 7200rpm 
Hard DriveOptical DriveOSMonitor
256GB SSD 8x DL "SuperDrive" OS X 10.7 Lion 27" 2560x1440 iMac display 
Monitor
27" Apple thunderbolt display 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › C++ Fraction Calculator