i have dev 4.9.9.1...i will create a win 32 console application.. write some code omething basic like...


//REMAIN.CPP
#include <iostream.h> //necessary for cin and cout commands

int main()
{

int dividend, divisor;

//get the dividend and divisor from the user
cout << "enter the dividend ";
cin >> dividend;
cout << "enter the divisor ";
cin >> divisor;


//output the qoutient and the remainder.
cout << "the qoutient is " << dividend/divisor;
cout << "with a remainder of " << dividend % divisor << '\n';
return 0;
}

the problem is after i (the user) fills in the dividend and divsor the program doesnt post the conclusion of the code....in fact, the console just closes before i can figure out whats up. i read what the warning says at the bottom of the compiler. it says.
"[warning] no new line at the end of file."

please assist. :(

>>#include <iostream.h>
First it's about C++, not DevC++...
<iostream.h> is deprecated; use <iostream> instead; this implies using namespace std; right after include headers section.

>>"[warning] no new line at the end of file."
Some compilers require "a new line at the end of file." Hit the "Enter" key right after the last curly bracket.

>>the console just closes before i can figure out whats up.
Add

cin.get();

before return 0;

With iostream you need to put std:: before cin and cout.
I have dev-cpp and this code works.

#include <iostream> 
int main()
{

int dividend, divisor;

std::cout << "enter the dividend ";
std::cin >> dividend;
std::cout << "enter the divisor ";
std::cin >> divisor;
std::cout << "the qoutient is " << dividend/divisor;
std::cout << "with a remainder of " << dividend % divisor << '\n';
return 0;
}

><iostream.h> is deprecated
No, it isn't. A deprecated feature has to have been a part of the standard in the first place. <iostream.h> was never a standard header.

>With iostream you need to put std:: before cin and cout.
There are three options for qualifying a namespace. First, you can qualify each use of a name by prefixing it with std::. Second, you can qualify all uses of a single name by saying using std::<name>;. And last, you can qualify all uses of every name in the std namespace by saying using namespace std;.

the problem is after i (the user) fills in the dividend and divsor the program doesnt post the conclusion of the code....in fact, the console just closes before i can figure out whats up.

YOU need to stop it closing. When it hits return 0; its all over. cin.get();, system("PAUSE"); (include <cstdlib>) , getchar(); (include <cstdlib>) works but if all else fails just use another cin >> divisor; hack. Why do people insist on std:: everything? why not put using namespace std; at the top :)

Just to rehash it all:

//REMAIN.CPP updated for Dev-C++

#include <iostream> //necessary for cin and cout commands

using namespace std;  // takes care of std::

int main()
{

  int dividend, divisor;

  //get the dividend and divisor from the user
  cout << "enter the dividend ";
  cin >> dividend;
  cout << "enter the divisor ";
  cin >> divisor;


  //output the qoutient and the remainder.
  cout << "the qoutient is " << dividend/divisor;
  cout << " with a remainder of " << dividend % divisor << '\n';

  cin.get();  // trap return
  cin.get();  // wait
  return 0;
}
// "[warning] no new line at the end of file." is a holdover from Unix

Good luck with your C++ experiments! And above all, practice, practice, practice!

Hi xxraveteddyxx,

Hey I am just interested by the Japanese characters you used. Are you native Japanese (or 'Nihongo' if you feel more comfortable with)?


Jim

>Are you native Japanese (or 'Nihongo' if you feel more comfortable with)?
I think you meant nihonjin. nihongo is the Japanese language, not a Japanese person. If you really did mean the Japanese language then your English grammar bites.

Narue you even know Japanese (Nihonjin) better than me (I am an Asian).

I have to admit that my English grammar is not that good............. So what? English is not 'the tongue of my mum' (mother tongue :mrgreen: )

Hi xxraveteddyxx,

Hey I am just interested by the Japanese characters you used. Are you native Japanese (or 'Nihongo' if you feel more comfortable with)?


Jim

Its just another thing im a student of...not my "mum tounge"...heh
chotto ninhongo o hanasu.
ョトニホンゴオナス

>Are you native Japanese (or 'Nihongo' if you feel more comfortable with)?
I think you meant nihonjin. nihongo is the Japanese language, not a Japanese person. If you really did mean the Japanese language then your English grammar bites.

Oh great... yet another language she can rip on people for. Thanks a lot, gang! ;)

:D

This question has already been answered. Start a new discussion instead.