Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I think it is related to the bit width of long in the particular machine.

int a;
	long b;
	char c;
	float d;
	double e;
	
	std::cin >> a >> b >> c >> d >> e;
	std::cout << a << std::endl;
	std::cout << b << std::endl;
	std::cout << c << std::endl;
	std::cout << d << std::endl;
	std::cout << e << std::endl;


What I have tried:

It is not working on these inputs.
211916801 97592151379235457 p 19856.992 -5279235.721231465


as output i am getting is:
211916801
2147483647
╠
-1.07374e+08
-9.25596e+61
Posted
Updated 21-Jun-19 10:02am

I'm not a C++ programmer but ...
2147483647 is 2^31 - 1 which suggests long is 4 bytes. If you Google (for example) cpp long bit width you will find

c++ faq - What does the C++ standard state the size of int, long type to be? - Stack Overflow[^]

which I'll let you read for yourself - it gives all the clues that you need.
 
Share this answer
 
Comments
[no name] 21-Jun-19 16:05pm    
+5
Quote:
97592151379235457

is too big for a 32-bit machine.
It is worth nothing cin provides some hint about, try:
C++
#include <iostream>
using namespace std;

int main()
{

  int a;
  long b;
  char c;
  float d;
  double e;

  cout << "size_of long = " << sizeof(long) << endl;

  cin >> a;
  cout << boolalpha;
  cout << cin.good() << endl;

  cin >> b;
  cout << cin.good() << endl;

  cin >> c;
  cout << cin.good() << endl;

  cin >> d;
  cout << cin.good() << endl;

  cin >> e;
  cout << cin.good() << endl;

  cout << a << endl;
  cout << b << endl;
  cout << c << endl;
  cout << d << endl;
  cout << e << endl;
}
 
Share this answer
 
Comments
[no name] 21-Jun-19 16:05pm    
+5
CPallini 21-Jun-19 16:18pm    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900