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
#include <iostream>
usingnamespace std;
constchar 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;
}
elseif (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;
}
elseif (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;
}
elseif(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;
}
elseif(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;
}
}
#include <iostream>
usingnamespace std;
constchar 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;
}
elseif (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;
}
elseif (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;
}
elseif(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;
}
elseif(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;