Can anyone help me? my problem is that when i enter my full name it forcefully close. i don't know why. please help me with my problem

#include <iostream>
#include <string>
using namespace std;

    string name, zodiac, horoscope;
    int age, month, day;

    cout<<"Enter your Full name: ";
    cin>>name;
    cout<<"Enter Age: ";
    cin>>age;
    cout<<"Enter Birth Month [1-12]: ";
    cin>>month;
    cout<<"Enter Birth Day [1-31]: ";
    cin>>day;
    cout<<"************************************************" <<endl;

    if((month==1)&(day>=20)|(month==2)&(day<=18)){
        zodiac="Aquarius";
        horoscope="The Sun in your sign squares Saturn in Scorpio on February 11, while the Moon in Cancer opposes Venus in Capricorn. As a result, you're going to feel as if your logic is flying in the face of what others call logic, and yet you're still going to feel justified in your actions. You may have to be cautious in what you do early in the year, but you're not going to be happy just bowing to the wishes of people around you, either. ";
    }
    else if ((month==2)&(day>=19)|(month==3)&(day<=20)){
        zodiac="Pisces";
        horoscope="One thing to remember is to pace yourself. Some people might be trying to take advantage of your good nature. With Mars and Saturn both in Scorpio in August, someone might not even be too subtle about using you. Keep your distance as best as you can, even if the devious person in question is the friend of someone you care about. ";
    }
    else if ((month==3)&(day>=21)|(month==4)&(day<=19)){
        zodiac="Aries";
        horoscope="if you thought 2014 would be dull, think again. And again. And again! Because, for certain, this will be a year when you'll do a lot of reassessment. For some people, especially the Aries, this could threaten to sink into self-absorption. But with all that's happening, especially with the Capricorn Moon in late January causing a flurry of excessive self-examination, you certainly have the right to be introspective.";
    }
    else if ((month==4)&(day>=20)|(month==5)&(day<=20)){
        zodiac="Taurus";
        horoscope="The Annular Solar Eclipse on April 28-29 should bring your social and private life to a pleasant and steady rhythm. The summer promises a more synchronized and steady routine that will allow you to stay focused on important tasks and chores while granting you the free time to get out and have fun with friends. ";
    }
    else if ((month==5)&(day>=21)|(month==6)&(day<=20)){
        zodiac="Gemini";
        horoscope="Your aims this year are going to make you very single-minded. You will likely have a personal financial goal that will prompt a do-or-die feeling all year. You're going to face a number of planetary influences that will have you measuring your progress, thus giving you a concrete feeling of moving ahead. ";
    }
    else if ((month==6)&(day>=21)|(month==7)&(day<=22)){
        zodiac="Cancer";
        horoscope="Dreams, ideas, and personal connections are going to be extremely valuable to you at the beginning of this year. You have a lot of ideas to sort through, and your friends can be very helpful in making this happen. Some of these ideas can seem very powerful, and others can seem a bit peculiar, but none of them should be dismissed. Jupiter is in your sign at the beginning of the year, and he's giving an approving nod to your idea-making. ";
    }
    else if ((month==7)&(day>=23)|(month==8)&(day<=22)){
        zodiac="Leo";
        horoscope="Because of this, you're going to be faced with fresh, interesting new challenges that might require you to be on your toes more often. Friends may come to you with interesting puzzles for you to solve. Family may be looking to you for advice that will help a loved one out of a crisis. ";
    }
    else if ((month==8)&(day>=23)|(month==9)&(day<=22)){
        zodiac="Virgo";
        horoscope="A friend or acquaintance will be amazed at what a treasure trove of helpful information you are. At first, you may be dismissive because you'll have so much on your plate you can barely think about yourself! But in the end, this could well be a channel for a new network of friends or acquaintances, thus opening up a new world for you! This is one of those times when just being yourself will pay off a hundredfold. ";
    }
    else if ((month==9)&(day>=23)|(month==10)&(day<=22)){
        zodiac="Libra";
        horoscope="On one hand, this is going to increase your personal network. On the other hand, you could find that people who need your skills will be coming to you more often. While you definitely like to help now and again, you're going to have to learn to say no occasionally if it severely interferes with your life. ";
    }
    else if ((month==10)&(day>=23)|(month==11)&(day<=21)){
        zodiac="Scorpio";
        horoscope="The level of familiarity you might have with friends, acquaintances, and neighbors might be equally unnerving and exhilarating. But don't worry! You'll be getting something out of it as well. ";
    }
    else if ((month==11)&(day>=22)|(month==12)&(day<=21)){
        zodiac="Sagittarius";
        horoscope="Some of your more personal goals may take a while to achieve, but the path to solving them is strewn with solutions to questions you'd lost hope in answering. Your personal energy level may slide a little in periods here and there in the summer, but you've got enough going so that friends can carry you during those low points. ";
    }
    else if ((month==12)&(day>=22)|(month==1)&(day<=19)){
        zodiac="Capricorn";
        horoscope="With Jupiter in Cancer most of the year and opposing planets in your sign at every turn, you may find yourself knee deep in home maintenance. And this doesn't just mean upkeep of your physical residence. It also means keeping family and romantic ties strong with a certain amount of effort. The work required will often be pleasant, but if you've ever wanted a reason to avoid laziness, this is it. ";
    }
    else{
        cout <<"INVALID MONTH OR DAY" <<endl;
        return 0;
    }
    cout <<"Zodiac Sign: " <<zodiac <<endl;
    cout <<"Your Horoscope: " <<horoscope <<endl;
    system("pause");
    return 0;


}

Recommended Answers

All 3 Replies

If you name has a space in it then you need to use getline() and not >>. You need to make sure that you "flush" the input stream if you do a call to >> and then use getline()(mixing input operations)

On what part sir?

Where is int main()?
put it before line 5

#include <iostream>
#include <string>

using namespace std;

int main(){

    //write everything here

    return 0
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.