Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

I want to use this program but the if statement is accepting all values.

0 votes
asked Oct 19, 2018 by Astrid Perez (120 points)
#include <iostream>

using namespace std;

int cake;
int BIRTHDAY;

int main()
{
    
    cout<<"Happy Birthday (Press 1 to start the happy birthday program)"<<endl;
    cin>>cake;
    if(cake = 1) {
    cout<<"                    *     *    *    * "<<endl;
    cout<<"                   ***   ***  ***  ***"<<endl;
    cout<<"                    *     *    *    * "<<endl;
    cout<<"                    *     *    *    * "<<endl;
    cout<<"                  *********************"<<endl;
    cout<<"                *************************"<<endl;
    cout<<"              ******************************"<<endl;
    cout<<"            **********************************"<<endl;
    cout<<"          **************************************"<<endl;
    cout<<"        ******************************************"<<endl;
    cout<<"      **********************************************"<<endl;    
    cout<<"    **************************************************"<<endl;
    cout<<"  ******************************************************"<<endl;
    cout<<"  ******************************************************"<<endl;
    cout<<"  ( **************************************************  )"<<endl;
    cout<<"  (   **********************************************    )"<<endl;
    cout<<"  (     ******************************************      )"<<endl;
    cout<<"  (       **************************************        )"<<endl;
    cout<<"  (         **********************************          )"<<endl;
    cout<<"  (           ******************************            )"<<endl;
    cout<<"  (             **************************              )"<<endl;
    cout<<"  (_______________**********************________________)"<<endl;
        
    }
    cout<<"Now it is time for your Present!(Type 72)"<<endl;
    cin>>BIRTHDAY;
    
    if(BIRTHDAY = 72)    {
    cout<<"    ******************************************************"<<endl;
        
        
        
        
    }
    return 0;
}

1 Answer

0 votes
answered Oct 19, 2018 by Fady Serhan (420 points)

The errors:-

1) if(cake==1) NOT if(cake=1)
2)if(Birthday==72) NOT if(Birthday=27)

you just put assigment not statment inside the if.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...