fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. //all commets are my predictions for the codes outcome.
  6. int a;
  7. //variable a is a whole number
  8. float b;
  9. //variable b can be a whole number or decimal
  10. char c;
  11. //variable c is a single letter or character
  12. string d;
  13. //variable d is a combination of characters
  14. cin >> a;
  15. //take in a whole number
  16. cout << a << endl;
  17. //read till the first decimal or/and white space (divider), which will be you whole number.
  18. //Starts at 1 and end at 3.
  19. cin >> b;
  20. //take in a decimal
  21. cout << b << endl;
  22. //read characters after the decimal until the next divider (decimal/white space)
  23. //continue from decimal and end at 6.
  24. cin.ignore (8);
  25. //Programm is at 6. It will now ignore 8 character (ws, 7, 8, 9, ws, N, N, & o) to then resume at t.
  26. getline (cin, d);
  27. //program is at t.
  28. //reads the rest of the string (combo of characters) until the next whitepsace
  29. cin >> c;
  30. //there are no more characters after the last line, so the next character is just white space.
  31. cout << c << endl;
  32. //nothing to output
  33.  
  34. //prediction is incorect. why isn't the string line outputted? How do I get it to output?
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0.01s 5328KB
stdin
123.456 789
NNot everyone eats mangos
stdout
123
0.456