Thank you for downloadi × -Sapling Learning Interact X Chegg Study Guided Sol. ×
ID: 3691222 • Letter: T
Question
Thank you for downloadi × -Sapling Learning Interact X Chegg Study Guided Sol. × Microsoft word-PA12.doc- + e https:muonline.blackboard.com/bbcswebdav/pid-2107848-dt-content-rid-16134053-1/courses/E a a Search Page: - + Automatic Zoom objective oi this ass1gnment. Read a 8 digits number from the input file. Separate it into 8 single digit numbers. Store those 8 single digit numbers into the output file Step 1 Open an input and an output file Step 2 Read contents (your student ID without L) from the input file Step 3 Split the student ID (8 digits number) into 8 single digits numbers. (See the output example below.) Step 4 Store the number read from the input file as well as the splitted 8 single digit numbers to the output file Step 5 Close both input and output files Input file example: inputl1.txt - Notepad File Edit Format View Help 20957230Explanation / Answer
#include<iostream.h>
#include<stdlib.h>
#include<fstream.h>
void main()
{
char infile[20], outfile[20];
long n;
int i, a[8],c=1;
cout<<"Enter the name of file you wish to open :";
cin>>infile;
ifstream in(infile);
cout<<"Enter the name of file you wish to write :";
cin>>outfile;
ofstream out(outfile);
//cout<<"The input number :"
in>>n;
cout<<"the input numbre :"<<n;
for(i=0;i<8;i++)
{
a[i]=n%10;
n=n/10;
}
for(i=7;i>=0;i--)
{
cout<<"The number "<<c<<" :"<<a[i]<<endl;
out<<"The number "<<c<<" : "<<a[i]<<endl;
c++;
}
system("pause");
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.