Write a Cpp program to read names from two files and store the result of concate
ID: 3766657 • Letter: W
Question
Write a Cpp program to read names from two files and store the result of concatenation and the length of the name in the third file. Example : Input File1 contains Firstname Sundeep Stephen Avinash Teja Subba Manisha Sindhu Input File 2 contains Lastname Sudalagunta Haa potu Koganti Chowdary Korrapati Tatineni Output File Firstname Lastname length-> 17 Sundeep Sudalagunta length-> 18 Stephen Haa length-> 10 Avinash potu length-> 11 Teja Koganti length-> 11 Subba Chowdary length-> 13 Manisha Korrapati length-> 16 Sindhu Tatineni length-> 14
Explanation / Answer
code:
#include <bits/stdc++.h>
using namespace std;
int main(){
ifstream inf1,inf2;
inf1.open("File1");
inf2.open("File2");
string s1,s2;
ofstream outf;
outf.open("output");
while(inf1>>s1 && inf2>>s2){
outf<<s1<<" "<<s2<<" length-> "<<s1.length()+s2.length()<<endl;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.