cout statement in cutting off

hi i am a beginner in c++
i have an assignment due and tried to make it interesting but the statements words are being cut off on the next line when it runs- i am sorry for not being able to phrase myself correctly and was wondering if there is a way that whole words will go to the next line and not be cut off
this is a part of the code... thank you for any input you can give me XD

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
using namespace std;
const char newline = '\n';

int main () 

{
//...there was a sort of storyline before this TT-TT
cout << "To see if you qualify enter your age in years (followed by 'enter') also to all female sapiens do remember that this information will be kept slightly          confidential"<<endl;//prompt
  cout <<  newline;cout <<  newline;
  int age; // age is a variable of type string (replace with int
  cin >> age; // read characters into age
  cout <<  newline;cout <<  newline;
  if (age> 0 && age < 12){
                cout<<"Your homo sapien body is " << age << " years old. Congratulations you qualify for child    labour and can therefore answer the next two questions which will test your     mathematical and scientific knowledge with very simple questions"<<endl;
               }
  else if (age>=13 && age<18){
                cout<<"Your homo sapien body is " << age << " years old. Congratulations you qualify even though  you are at the rebellious stage of your life and can therefore answer the next  two questions which will test your mathematical and scientific knowledge with   very simple questions"<<endl;
                              }

  else if (age>=18 && age<50){
        cout<<"Your homo sapien body is " << age << " years old. Congratulations you qualify and can      therefore answer the next two questions which will test your mathematical and scientific knowledge with very simple questions"<<endl;
                             }
  else if(age>=50){
    cout<<"Your homo sapien body is " << age << " years old. Congratulations you qualify for selling  your cadavre at no cost and can therefore answer the next two questions which   will help implode your brain faster..."<<endl;

  }
  else if(age<= 0){
    cout<<"Your homo sapien body is " << age << " years old. Congratulations I have nowhere to place you...but we will be looking forward to tasting your cadavre. Please feel free to answer the next two simple questions as a token of our gratitude for selling  your cadavre at no cost."<<endl;

  }
}
Last edited on
Use the code tags, reading code out of context is an eyesore.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
using namespace std;
const char newline = '\n';

int main () 

{
//...there was a sort of storyline before this TT-TT
cout << "To see if you qualify enter your age in years (followed by 'enter') also to all female sapiens do remember that this information will be kept slightly confidential"<<endl;//prompt
cout << newline;cout << newline;
int age; // age is a variable of type string (replace with int
cin >> age; // read characters into age
cout << newline;cout << newline;
if (age> 0 && age < 12){
cout<<"Your homo sapien body is " << age << " years old. Congratulations you qualify for child labour and can therefore answer the next two questions which will test your mathematical and scientific knowledge with very simple questions"<<endl;
}
else if (age>=13 && age<18){
cout<<"Your homo sapien body is " << age << " years old. Congratulations you qualify even though you are at the rebellious stage of your life and can therefore answer the next two questions which will test your mathematical and scientific knowledge with very simple questions"<<endl;
}

else if (age>=18 && age<50){
cout<<"Your homo sapien body is " << age << " years old. Congratulations you qualify and can therefore answer the next two questions which will test your mathematical and scientific knowledge with very simple questions"<<endl;
}
else if(age>=50){
cout<<"Your homo sapien body is " << age << " years old. Congratulations you qualify for selling your cadavre at no cost and can therefore answer the next two questions which will help implode your brain faster..."<<endl;

}
else if(age<= 0){
cout<<"Your homo sapien body is " << age << " years old. Congratulations I have nowhere to place you...but we will be looking forward to tasting your cadavre. Please feel free to answer the next two simple questions as a token of our gratitude for selling your cadavre at no cost."<<endl;

}
}
Also, here is a list of character codes (http://en.cppreference.com/w/cpp/language/escape), including the '\n' character code which results in a newline. Try to not declare special characters as constants or as variables, it is not needed. Instead, try either just inserting '\n' at the end of string output, or an endl;
1
2
std::cout << "This is a string, the last character ends the line\n";
std::cout << "This is a string, we will use the endl instead." << std::endl;
Last edited on
Thank you so much it means a lot
You're welcome! If you don't have any more questions don't forget to mark thread as solved! :)
Topic archived. No new replies allowed.