C++ Worksheet 10-1-1
C++ Worksheet 10-1-1
Aim of Experiment - WAP to copy the contents of one file to another and display it on output
screen.
Create two files say codes.txt and cracker.txt inside the same directory where you're saving our
C++ source code. That is, either:
Create two files inside the directory where you're saving your program or going to save your C++
program of copy file (given below)
Or save your C++ program (that copies the content of one file to another) in that folder where the
two files codes.txt and
cracker.txt are created.
Algorithm –
STEP 1: START
File*fs,*ft
STEP5:Input the name of source file and pass through fopen(…)method and
store in fs
STEP 8:ch=fget(fs)
STEP 9:if(ch!=EOF)
STEP10:fput(ch,ft)
Aim of Experiment –WAP to read the class object of student info such as name, age and roll
no from the keyboard and to store them on a specified file using read() and write()functions. Again the same
files opened for reading and displaying the contents of the file on the screen.
Algorithm –
STEP 1: START
STEP 2: Declare Header file and namespace and declare a class Student
STEP 6: In main method declare student object, ofstream file STEP 7: open the
STEP 8: if(file is not present then print “Error message”) else print ”file created
successfully ”
STEP14: again open the file in read mode STEP 15: read
Using fget and null void function to derive & coly the data to output. we are able to pront required
results
2. In this program we store , record and print a set of data.. initially the input is stores in read() and
write () function and then we create getdata() amd showdata(), using fstream we link the two and
print our appropriate results.
LEARNING OUTCOMES
Identify situations where computational methods would be useful.
Approach the programming tasks using techniques learnt and write pseudo-code.
Choose the right data representation formats based on the requirements of the problem.
Use the comparisons and limitations of the various programming constructs and choose the
right one for the task.
3. Student engagement in 5
Simulation/ Performance/ Pre Lab
Questions
4. Total Marks 20