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

Programming Fundamentals: Modes

The document contains instructions for 6 programming tasks in C++. Task 1 involves writing a program to add a user-input string to the beginning of a text file. Task 2 passes a user-input number to a function to display powers of 2 up to that number. Task 3 passes two user-input integers to a function that returns their sum. Task 4 passes a student's marks to a function that returns their grade. Task 5 passes a student's grade to a function that returns the curved grade. Task 6 passes two values to a function that either returns their sum if it exceeds 25 or returns the values increased by 10.

Uploaded by

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)
56 views3 pages

Programming Fundamentals: Modes

The document contains instructions for 6 programming tasks in C++. Task 1 involves writing a program to add a user-input string to the beginning of a text file. Task 2 passes a user-input number to a function to display powers of 2 up to that number. Task 3 passes two user-input integers to a function that returns their sum. Task 4 passes a student's marks to a function that returns their grade. Task 5 passes a student's grade to a function that returns the curved grade. Task 6 passes two values to a function that either returns their sum if it exceeds 25 or returns the values increased by 10.

Uploaded by

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