Write a program that ask the user for a number from 1 to 5, then the number give
ID: 3765176 • Letter: W
Question
Write a program that ask the user for a number from 1 to 5, then the number given will represent the number of names that the user has to input. The names are composed of first and last name, and could also include a middle name. You might request the user to write the names beginning with the last name. Then all those names have to be written down to a file in alphabetical order based on the last names first. Besides the “main()” you have to use at least other two functions. Hint: you might use a function to swap the strings.
Please, use C++ or basic concepts. This is for an intro to computing class
Write a program that ask the user for a number from 1 to 5, then the number given will represent the number of names that the user has to input. The names are composed of first and last name, and could also include a middle name. You might request the user to write the names beginning with the last name. Then all those names have to be written down to a file in alphabetical order based on the last names first. Besides the “main()” you have to use at least other two functions. Hint: you might use a function to swap the strings.
Please, use C++ or basic concepts. This is for an intro to computing class
Write a program that ask the user for a number from 1 to 5, then the number given will represent the number of names that the user has to input. The names are composed of first and last name, and could also include a middle name. You might request the user to write the names beginning with the last name. Then all those names have to be written down to a file in alphabetical order based on the last names first. Besides the “main()” you have to use at least other two functions. Hint: you might use a function to swap the strings.
Please, use C++ or basic concepts. This is for an intro to computing class
Please, use C++ or basic concepts. This is for an intro to computing class
Explanation / Answer
#include<iostream.h>
#include<fstream.h>
void fileins(char l[], char f[], char m[])
{
ofstream out;
out.open("details.txt",ios::app);
out<<l<<" "<<f<<" "<<m<<endl;
out.close();
}
void main()
{
char last[20],first[20],mid[20];
int n,i;
cout<<"Enter number between 1 to 5";
cin>>n;
ofstream out;
for(i=0;i<n;i++)
{
cout<<"Enter Last name";
cin>>last;
cout<<"Enter First name";
cin>>first;
cout<<"Enter Middle name";
cin>>mid;
fileins(last,first,mid);
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.