0% found this document useful (0 votes)
35 views3 pages

Lab 04 Manual

The document outlines 6 programming tasks involving functions and file input/output in C++. The tasks include adding a string to the start of a text file, passing values to functions to perform calculations and return results, and conditionally returning different values from a function based on the input values.

Uploaded by

Hafiz Hammad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views3 pages

Lab 04 Manual

The document outlines 6 programming tasks involving functions and file input/output in C++. The tasks include adding a string to the start of a text file, passing values to functions to perform calculations and return results, and conditionally returning different values from a function based on the input values.

Uploaded by

Hafiz Hammad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Programming Fundamentals

Lab 04
Modes:
In, Out, Ate, App, Trunc.

Task 1:
Write a C++ program to add the user input at the start of a text file (data.txt). A temporary file may be
helpful in this task.
Example:
Input:
data.txt
Ahmad Munir
Adeel Anwar
Yasir Arif
Ahmar Mohsin

Enter String: Abid Waqar


Output:
data.txt
Abid Waqar
Ahmad Munir
Adeel Anwar
Yasir Arif
Ahmar Mohsin

Task 2:
Write a C++ program to pass a user input(Integer) to a function and display two’s power up to given
input inside the callee function.
Example:
Input:
Enter Number: 4
Output:
𝟐𝟒 = 16

Task 3:
Write a C++ program to pass user input (two Integer’s) to a function and return their sum to the caller
function in order to display in there.
Example:
Input:
Enter Number 1: 12
Enter Number 2: 19
Output:
Sum (12,19) = 31

Task 4:
Write a C++ program to pass marks of a Student (User Input) to a function and return the grade
according to new UCP Grading Policy.
Example:
Input:
Enter Marks of a Student: 80
Output:
Grade (80) = B

Task 5:
Write a C++ program to pass the grade a Student (User Input) to a function and return the grade after
performing curving of two grades through ascii value. Grades being considered are only (A, B, C, D, F).
Example:
Input:
Enter Grade of a Student: C
Output:
Grade (After Curving) = A

Task 6:
Write a C++ program to pass user input (two values) to a function and return their sum if it is greater
than 25 otherwise return both values after adding 10 in them.
Example 1:
Input:
Enter Number 1: 10.5
Enter Number 2: 7
Output:
Sum (10.5,7) = 20.5 17
Example 2:
Input:
Enter Number 1: 20.5
Enter Number 2: 17
Output:
Sum (20.5,17) = 37.5

You might also like