0% found this document useful (0 votes)
61 views

PF Lab Semester Assignment by 19sw01

The document contains details of programming assignments for a programming fundamentals lab. It lists 14 tasks that involve writing C++ programs to perform operations like declaring variables, swapping values, converting units, checking character properties, using loops, structures, functions and arrays. For each task, the required code and output is listed.

Uploaded by

Tooba Akhtar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

PF Lab Semester Assignment by 19sw01

The document contains details of programming assignments for a programming fundamentals lab. It lists 14 tasks that involve writing C++ programs to perform operations like declaring variables, swapping values, converting units, checking character properties, using loops, structures, functions and arrays. For each task, the required code and output is listed.

Uploaded by

Tooba Akhtar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 61

Assignment

Programming
Fundamentals
Lab Tasks

Roll Number: 19SW01


Date: 15/Feb/2020
Lab 1, 2&3 Tasks:
Task 01:
19SW01
Try to guess what each line of code is doing.

19SW01
Task 02
Write C++ programs in which declare some variables with valid
identifiers and conventions rule, to hold your name, your total
marks in pervious semester, percentage, your grade, your
status of pass or fail etc, assign them explicitly and print them.
Program Code:

19SW01
Program Output:

19SW01
Task 03
Write a program to swap two variables.
Program Code:

Program Output:

19SW01
Task 04
Write a Program named Address.cpp .An address has
 Student name
 A house number
 A street
 A city
 A state and
 A postal code
Program Code:

19SW01
Program Output:

19SW01
Task 05
Write a C++ program to print the ASCII value of a given
character.
Program Code:

Program Output:

19SW01
Task 06
Write a program that prints out the \n character on the screen.
Program Code:

Program Output:

19SW01
Task 07
Consider the variable char character = ‘A’;
Print the character in single quotes: ‘A’
Program Code:

Program Output:

19SW01
Task 08
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.
Program Code:

Program Output:

19SW01
Task 09
Write a C++ program to convert hours to minutes and minutes
to seconds.
Program Code:

Program Output:

19SW01
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.
Program Code:

Program Output:

19SW01
Task 11
Write a C++ program that takes an uppercase character from
the user and display its equivalent lowercase character.
Program Code:

Program Output:

19SW01
Task 12
Write a C++ program, which takes three integer values from the
user, and print their addition and average.
Program Code:

Program Output:

19SW01
Task 13
In the following code, explain why the value “6” is printed twice
in a row:

19SW01
Task 14
Write a C++ program to print a face.
Program Code:

Program Output:

19SW01
Lab 4 tasks
Task 01
Write a C++ program to allow the user to input his/her age.
Then the program will show if the person is eligible to vote.
Program Code:

Program Output:

19SW01
Task 02
A student will not be allowed to sit in exam if his / her
attendance is less than 75%.Print %age of classes attended. Is
student allowed to sit in the exam?
Program Code:

Program Output:

19SW01
Task 03
Write a program that accepts three numbers from the user and
prints increasing if the numbers are in increasing order,
decreasing if the numbers are in decreasing order.
Program Code:

Program Output:

19SW01
Task 04
Write a program to check whether a entered character is lower
case or upper case.
Program code:

Program output:

19SW01
Task 05
Write a C++ program that takes a line of text from the user and
prints only the first word.
Program code:

Program output:

19SW01
Task 06
Write a C++ program that takes a single word from the user and
prints only the first character.
Program code:

Program output:

19SW01
Task 07
In the following program, explain why the value 6 is printed
twice in a row.

19SW01
Task 08
Take 3 numbers from the user and print greatest number.
Program code:

Program output:

Task 09

19SW01
Write C++ programs that accept three numbers and print all
numbers are equal if all three numbers are equal.
Program code:

Program output:

19SW01
Task 10

19SW01
Lab 04 Tasks
Task 01:
Generate alphabets from A to Z.
Program Code:

Program Output:

19SW01
Task 02:
Generate a series of odd numbers and even numbers using for or
while loop.
Program Code:

Program Output:

19SW01
Task 03:
Write a program that prints all roll numbers of your class using
for loop.
Program Code:

Program Output:

19SW01
Task 04:
Consider task 01 and separate vowels and consonants.
Program Code:

Program Output:

Task 05:
19SW01
Write a program to print the table of characters that are
equivalent to the ASCII codes from 97 to 122. The program will
print 10 characters per line.
Program Code:

Program Output:

19SW01
Task 06:
Write a C++ program that takes two characters as an input and
display all the characters between these two. Also count the
number of characters.
Program Code:

Program Output:

19SW01
Task 07:
Write a program to produce the sum of 1, 2, 3, to 100. Also
compute and display the average.
Program Code:

Program Output:

19SW01
Task 08:
Write a program that prints the table of number 5 up to 15.
Program Code:

Program Output:

Task 09:

19SW01
Write a program that takes an integer as an input and prints its
factorial.
Program Code:

Program Output:

Task 10:
What the loops below do?

19SW01
19SW01
19SW01
19SW01
Lab 06 Tasks
Task 01:
Create a structure called employee that contains four members:
 Name of employee
 Designation of employee
 An employee number
 The employee’s salary
Ask the user to fill this detail for two employees, store it in two
variables of type structure and then display the information for
both employees.

Program Code:

19SW01
19SW01
Program Output:

Task 02:

19SW01
Create a structure called students that contains two numbers:
Student’s obtained marks
Total marks
Ask the user for obtained marks and total marks, store it in a
variable of type structure, and then display the percentage.
Program Code:

Program Output:

19SW01
19SW01
Task 03:
Bank Management System:
Program Code:

19SW01
Program Output:

19SW01
19SW01
Lab 07 Tasks
Task 01:
Create a function called Largernum() that receives two integer
numbers as arguments and returns the Larger number out of
them.
Program Code:

Program Output:

19SW01
19SW01
Task 02:
Write a function called zeroSmaller() that takes two integer
arguments by reference and then sets the smaller of the two
numbers to 0. Write a main function to exercise this function.
Program Code:

Program Output:

19SW01
19SW01
Task 03:
Write a function called swap() that interchanges two integer
values passed to it by the calling program.
Program Code:

Program Output:
19SW01
19SW01
Lab 08 Tasks
Task 01:
Write a C++ program that creates and initializes an array of type
integer as: int array[]={5, 10, 15, 20, 25}; and computes the
sum of the elements in an array.
Program Code:

19SW01
Program Output:

19SW01
Task 02:
Consider the array in Task no. 1. Write a C++ program that
prints all the elements of the array in reverse order.
Program Code:

Program Output:

19SW01
Task 03:
Write a C++ program that prints the second last element in the
array created in task 1. And also display the sum and product of
last two elements of the array.
Program Code:

Program Output:

Task 04:

19SW01
Write a C++ program that finds the smallest element in the array
and also its index.
Program Code:

Program Output:

Task 05:

19SW01
Write a C++ program that finds the largest element in the array
and also its index.
Program Code:

Program Output:

Task 06:

19SW01
Write a C++ program that passes an array as an argument to a
function.
Program Code:

Program Output:

19SW01
19SW01

You might also like