+ 1
[SOLVED] Hi Guys, I need to run a program on C++ that prints my first name and last name.
My last name also needs to be preceded by as many hyphens as character that I have in my first name. An example would be: Robert ------ Smith. Thanks in advance.
3 Respostas
+ 2
Kristo Papa Check your 5th cout line after cout<<"Your name preceded by hyphens is :"<<fname<<""<<lname<<" "<<------<<""endl ;
You use wrong endl and hyphens your hyphen should be in double quotes and before last endl you have to write (<<) means <<endl ;
See this
#include<iostream>
#include<string>
using namespace std;
int main()
{
char fname[30], lname [30];
cout << "\n\n Print your name:\n";
cout << "-----------------------------------------------------------\n";
cout << " Input First Name: ";
cin >> fname;
cout << " \nInput Last Name: ";
cin >> lname;
cout << " \nYour name preceded by hyphens is: "<< fname << " "<<lname << " " <<"------ "<< "" <<endl;
cout << endl;
return 0;
}
+ 8
It'd be friendlier to the eyes Kristo Papa if you linked your code from Code-Playground.
+ 4
Hello Kristo Papa
Please don't ask for codes here.
Please show us your attempt, so we can help you.