Hey, I am new to programming and I was trying to make a basic add program. It is working fine until it asks you if you want to do it again and no matter if I push y or n it does nothing. What am I missing?
Code:#include <iostream> using namespace std; int mult (int a, int b); int main() //Trying to make a basic add program. After you add will ask if you want { //to do another problem but isn't. to try and simplize the program erased int a; //code to make program repeat when you do again and simply put it works int b; //until i can find out why if statement is not working. char y, n; cout<<"Please input the two numbers to be added: "; cin>> a >> b; cin.ignore(); cout<<" The sum of the two numbers is: "<< mult (a, b) <<"\n"; cin.get(); cout<<"Would you like to add again? (y/n): "; cin>> y >> n; cin.ignore(); if ( y == y ) { cout<<"It works\n"; } } int mult (int a, int b) { return a + b; }



LinkBack URL
About LinkBacks


