Write a C++ program where you should ask the user to input his/her first and last names and create/print an @iba-suk.edu.pk email address with the entered first name and last name. For example, if the first name is riaz and the last name is ali, then the program should make and print riaz.ali@iba-suk.edu.pk email address.
#include <iostream>
#include <string>
using namespace std;
int main()
{
string user_name;
cin >> user_name;
cout << user_name.append("@iba-suk.edu.pk");
return 0;
}
Or
#include <iostream>
#include <string>
using namespace std;
int main()
{
string user_name;
cin >> user_name;
cout << user_name+"@iba-suk.edu.pk";
return 0;
}
Or
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main()
{
string user_name;
cin >> user_name;
char *email = new char[user_name.length()];
for (int i = 0; i <= user_name.length(); i++)
{
email[i] = user_name[i];
}
cout << strcat(email,"@iba-suk.edu.pk");
return 0;
}
cpp programming exercise with solution |