New Posts  All Forums:Forum Nav:

C++ help.

post #1 of 4
Thread Starter 
I am having trouble understanding this program and hope somebody could clarify it for me.

#include

using namespace std;

int main()
{
int num;

cin >> num;

while (num != -999)
{
cout << num % 25 << " ";
cin >> num;
}

cout << num << endl;
return 0;
}


The program runs, but I do not know exactly what it is doing.

The % means that you take the remainder right?

Basically I entered 58 and 8 is the out put.

In the program it would take 58, my input, and divide it by 25 right? That equals 2.32. So where does the 8 come from? Am I missing something?
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel i7 950 Asus P6X58D-E Gigabyte GTX 770  12 GB GSkill 
Hard DriveOptical DriveOSMonitor
Seagate 1TB, Samsung 2TB TSSTcorp Windows 7 home Premium x64 Asus 24" 1920*1080 x 2 
KeyboardPowerCaseMouse
WASD XFX 650 watt Cooler Master HAF 932 Logitech G500 
  hide details  
Reply
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel i7 950 Asus P6X58D-E Gigabyte GTX 770  12 GB GSkill 
Hard DriveOptical DriveOSMonitor
Seagate 1TB, Samsung 2TB TSSTcorp Windows 7 home Premium x64 Asus 24" 1920*1080 x 2 
KeyboardPowerCaseMouse
WASD XFX 650 watt Cooler Master HAF 932 Logitech G500 
  hide details  
Reply
post #2 of 4
Thread Starter 
nvm I realised my mistake.....
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel i7 950 Asus P6X58D-E Gigabyte GTX 770  12 GB GSkill 
Hard DriveOptical DriveOSMonitor
Seagate 1TB, Samsung 2TB TSSTcorp Windows 7 home Premium x64 Asus 24" 1920*1080 x 2 
KeyboardPowerCaseMouse
WASD XFX 650 watt Cooler Master HAF 932 Logitech G500 
  hide details  
Reply
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel i7 950 Asus P6X58D-E Gigabyte GTX 770  12 GB GSkill 
Hard DriveOptical DriveOSMonitor
Seagate 1TB, Samsung 2TB TSSTcorp Windows 7 home Premium x64 Asus 24" 1920*1080 x 2 
KeyboardPowerCaseMouse
WASD XFX 650 watt Cooler Master HAF 932 Logitech G500 
  hide details  
Reply
post #3 of 4
You made me type so much for nothing!!!!! D:

Lol j/k. Glad you figured it out by yourself. Good work! Any other doubts you can PM me :]
     
CPUMotherboardGraphicsGraphics
[Intel] Core i7 2630QM [Lenovo] 4239CTO [Intel](R) HD Graphics Family [NVIDIA] NVS 4200M  
RAMRAMHard DriveHard Drive
[Samsung] 4GB 1333MHz  [Corsair] 4GB 1333MHz [Patriot] Pyro 60GB Sata III  [Western Digital] Scorpio Black 500GB 7200rpm 1... 
Optical DriveOSOSMonitor
[Lenovo] DL-DT Drive [Microsoft] Windows 7 64-bit SP1 Professional Kubuntu 64bit 11.10 [LG] 15.6in 1600x900  
PowerCaseMouseMouse Pad
[Lenovo] Power Brick 130w [Lenovo] ThinkPad T520 [Logitech] G500 [Razr] Goliathus Medium 
  hide details  
Reply
     
CPUMotherboardGraphicsGraphics
[Intel] Core i7 2630QM [Lenovo] 4239CTO [Intel](R) HD Graphics Family [NVIDIA] NVS 4200M  
RAMRAMHard DriveHard Drive
[Samsung] 4GB 1333MHz  [Corsair] 4GB 1333MHz [Patriot] Pyro 60GB Sata III  [Western Digital] Scorpio Black 500GB 7200rpm 1... 
Optical DriveOSOSMonitor
[Lenovo] DL-DT Drive [Microsoft] Windows 7 64-bit SP1 Professional Kubuntu 64bit 11.10 [LG] 15.6in 1600x900  
PowerCaseMouseMouse Pad
[Lenovo] Power Brick 130w [Lenovo] ThinkPad T520 [Logitech] G500 [Razr] Goliathus Medium 
  hide details  
Reply
post #4 of 4
Thread Starter 
Will do thanks thumb.gif
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel i7 950 Asus P6X58D-E Gigabyte GTX 770  12 GB GSkill 
Hard DriveOptical DriveOSMonitor
Seagate 1TB, Samsung 2TB TSSTcorp Windows 7 home Premium x64 Asus 24" 1920*1080 x 2 
KeyboardPowerCaseMouse
WASD XFX 650 watt Cooler Master HAF 932 Logitech G500 
  hide details  
Reply
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel i7 950 Asus P6X58D-E Gigabyte GTX 770  12 GB GSkill 
Hard DriveOptical DriveOSMonitor
Seagate 1TB, Samsung 2TB TSSTcorp Windows 7 home Premium x64 Asus 24" 1920*1080 x 2 
KeyboardPowerCaseMouse
WASD XFX 650 watt Cooler Master HAF 932 Logitech G500 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming