In the last several tutorials we covered a lot of information quickly. In this tutorial we will recap a variety of the components that we have learned so far.

We will create a program that will input and output a string variable.  We will use an if statement to determine what data to output to the user.  This is a neat tutorial to quickly recap the information that we have learned so far.


/* Using Strings
   Nathan Neil */
   
   #include <iostream>

   using namespace std;

   int main() {
   	string name;
   	char birthday;
   	
   	//ask for users name
   	cout << "What is your Name: ";
   	cin >> name;
   	cout << "Is today your birthday: (y or n) ";
   	cin >> birthday;
   	
   	if(birthday == 'y'){
   		cout << "Happy Birthday, " << name;
	   }
	else{
		cout << "Welcome " << name <<", to C++!";
	}
   	
  	
	   return 0;
   		   	
}

 

Pin It on Pinterest

Share This

Share this post with your friends!

%d bloggers like this: