Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Programming in C++


  • Please log in to reply
5 replies to this topic

#1 Benjytim

Benjytim

  • Members
  • 3 posts
  • OFFLINE
  •  
  • Local time:11:43 AM

Posted 01 November 2010 - 03:31 AM

I ran this program in my compiler and it ran but the output-screen does not stay for me to see. what could be wrong with the program?

#include<iostream.h>
main()
{
int i=5, j=6, k=7, n=3;
cout<<i+j*k-k%n<<endl;
cout<<i/n<<endl;
system ("pause")
return 0;
}

Edited by hamluis, 01 November 2010 - 09:46 AM.
Moved from XP forum to Programming ~ Hamluis.


BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:10:43 AM

Posted 01 November 2010 - 12:20 PM

Don't run your program from the IDE, run it from the command line.

#3 NicoDev

NicoDev

  • Members
  • 41 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:France
  • Local time:05:43 PM

Posted 01 November 2010 - 03:29 PM

Hello

You can use getchar(); instead of system ("pause")

Nico

#4 Romeo29

Romeo29

    Learning To Bleep


  • Members
  • 3,194 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:127.0.0.1
  • Local time:11:43 AM

Posted 03 November 2010 - 05:39 PM

The code is all wrong.

- You have one semi-colon missing after system("pause")
- You are using <iostream.h> which is deprecated.
- The main() function should have an int return type.
- You are not using any namespace before cout and endl, like std::cout.

How did you compile it in the first place?

#5 kanraku

kanraku

  • Members
  • 10 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Canada
  • Local time:11:43 AM

Posted 09 November 2010 - 12:58 AM

He probably didn't compile at all, but that wouldn't explain the output screen...

Besides the DOS screen just running without compiling anything.

Maybe, he's not using an IDE?

A namespace for cout is missing.
Main is missing a type.

#6 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:10:43 AM

Posted 09 November 2010 - 05:27 PM

He probably didn't compile at all, but that wouldn't explain the output screen...


It probably displayed an error and then quit. You can see the exact same behavior if you go to your run box in the start menu and just type in ipconfig.exe. A box will display for a fraction of a second and then close. Same thing.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users