0% found this document useful (0 votes)
16 views4 pages

Lab 01 N1 - 2

Uploaded by

saad
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)
16 views4 pages

Lab 01 N1 - 2

Uploaded by

saad
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/ 4

University of Central Punjab

Faculty of Information Technology

Programming Fundamentals – Fall 2024


Lab 1 Guidelines
• Complete and submit all tasks within the lab session.
• Use of ChatGPT, other AI tools, or online code generation services is prohibited.
• Implement all tasks using C++ only.
• Directly copying code from classmates or online sources is not allowed; all submitted work must be your own.
• Do not use STL (Standard Template Library) built-in functions; implement functionality manually where
required.

Task 1
Write a program that takes a number as input and prints the factorial of that number.
Example:
Input: 5
Output: 120

Task 2
Write a program that takes a five-digit number, separates its digits, and save those digits in an array. Print
the array on screen.
Example:
Input: 34125
Output:

Index 0 1 2 3 4
value 3 4 1 2 5

1
Task 3
Find that whether a given char array of size 5 is palindrome or not.
Example:
Input: tibit
Output: yes
Input: talot
Output: No

Task 4
Write a program which take your name as input and display it on screen.
Sample output:
Input: Ali
Output: Ali

Task 5
Write a program which take 5 numbers from user and store in an array and display the maximum and
minimum number.
Sample output:
Input: 1 5 3 4 2
Min: 1
Max: 5

Task 6
Write a C++ program which takes a character array of size 10 as an input from user. Now search vowel
character in the array if character is vowel display it on screen.
Sample output:
Input:
Enter character array: aworldwoniw
Output: a o o i

2
Task 7
Write a program which takes 10 numbers from user. Take number from a user as input, search it in the
array if found delete the number and shift the array to left so that empty space move to the end.
Example:
Enter numbers: 1 2 3 4 5 6 7 8 9 10

1 2 3 4 5 6 7 8 9 10

Enter a number to delete: 5


1 2 3 4 6 7 8 9 10

Task 8
Write a program which take your name and find all repeating characters and display them.
Sample output 1:
Enter name: Ahmad
Output: a

Sample output 2:
Enter name: Abid Fareed

Output: a e d

Sample output 3:
Enter name: Abid

Output:

3
Task 9
Write a program that takes two-character arrays (c-strings) as input and checks if they are the same or
not. The comparison should not be case-sensitive, meaning uppercase and lowercase letters are treated
as the same.
Sample output 1:
Input:
Enter character array1: hello
Enter character array1: hello
Output: Both Arrays are same.

Sample output 2:
Input:
Enter character array1: hello
Enter character array1: hElLo
Output: Both Arrays are same.

Task 10
Write a C++ program that declares an array named alpha with 50 elements of type double. The first 25
elements of the array should be initialized to the square of their index (e.g., alpha[0] = 0^2=0, alpha[1] =
1^2=1, etc.), and the last 25 elements should be set to three times their index (e.g.,alpha[25] = 25 *
3=75, alpha[26] = 26 * 3=78, etc.). Your program should output the contents of the array, formatting the
display so that each line contains exactly 10 elements.
Sample output:
0 1 4 9 16 25 36 49 64 81
100 121 144 169 196 225 256 289 324 361
400 441 484 529 576 75 78 81 84 87
90 93 96 99 102 105 108 111 114 117
120 123 126 129 132 135 138 141 144 147

Submission Instructions:
• Submit only CPP files in a single ZIP folder.
• The name of each CPP file should be the question number. E.g., Q1.cpp
• The name of the ZIP folder should be your complete registration number. E.g., L1F20BSSE0000

You might also like