PF Assignment
PF Assignment
Programming
Fundamentals
Lab No.1,2 & 3 Tasks.
Roll Number:19SW08
Date:07/11/2019
2
Task # 1
Try to guess what each line of code 1. Declares and initializes an int
is doing. variable named ‘size’ and gives it
1. int size = 27; the value 27.
Task # 2
Write a C++ program in which declare some variables with
valid identifiers and conventions rule, to hold your name,
your total marks in previous semester, percentage, your
grade, your status of pass or fail etc, assign them explicitly
and print them. Try to declare variables of all data types and
assign the appropriate values.
Program Code:
4
Program Output:
Task#2.cpp
Task#2.exe
5
Task # 3
Write a C++ program to swap two variables.
Program Code:
6
Program Output:
Task#3.cpp
Task#3.exe
7
Task # 4
Program Code:
8
Task # 5
Write a C++ program to print the ASCII value of a given
character.
Expected Output
The ASCII value of Z is :90
Program Code:
9
Program Output:
Task#5.cpp
Task#5.exe
10
Task # 6
Write a class that prints out the \n character on the screen.
Program Code:
11
Program Output:
Task#6.cpp
Task#6.exe
12
Task # 7
Program Code:
13
Program Output:
Task#7.cpp
Task#7.exe
14
Task # 8
Write a program to declare and initialize a float variable
with some value such as 50.25. Then retrieve the integral
part and store it in the variable of type int, and the
fractional part and store it in a variable of type float.
Display actual number, integral part Fractional part.
Expected output:-
Number: 50.25
Integer part: 50
Fractional part: 0.25
Program Code:
15
Program Output:
Task#8.cpp
Task#8.exe
16
Task # 9
Write a C++ program to convert hours to minutes and
minutes to seconds
Sample Output:
Input Hours: 10
Minutes: 600
Seconds: 3600
Program Code:
17
Task # 10 Write a C++ program that declares and initializes an uppercase character
variable of your choice and display the next character in the alphabetical order.
Task # 11 Write a C++ program that takes an uppercase character from the user and display
its equivalent lower case character.
Expected output
Task # 12 Write a c++ program, which takes three int values from the user, and print their
addition and average.
Task # 13: In the following program, explain why the value "6" is printed twice in a row:
// PrePostDemo.cpp
int main() {
int i = 3;
i++;
cout<<i; // "4"
++i;
cout<<i; // "5"
cout<<++i; // "6"
cout<<i++; // "6"
out<<i; // "7"
18