Programming Fundamentals AD/BS 2 Semester/Term PU — University of the Punjab 2025
Discussion
Ask a question about this paper, or help someone else with theirs. Answers are emailed to whoever asked.
No questions yet — be the first to ask.
Need Paper?
See all →
Need a paper or stuck on a question? Ask here — students reply and you get an email.
Ask about a paper-
BS ZOOLOGY first semester Animal diversity ZOOL 101 - university of Punjab 2025
0 replies Reply → -
Literary criticism
1 reply Reply → -
this paper consists of 60 marks but now we have 35 marks paper.
1 reply Reply → -
Can you please tell me more past papers please because my exams are starting from next week
1 reply Reply → -
Did you provide the past papers of the science of society uos?
1 reply Reply →
More Programming Fundamentals papers
See all
Programming Fundamentals BS Software Engineering/MPhil Information Technology/MS Information Technology 1 Semester/Term UOS — University of Sargodha 2017
Uploaded 1 day ago · by Hifza
Download ↓
Programming Fundamentals BS 1 Semester/Term 2016
Uploaded 1 day ago · by Hifza
Download ↓
Programming Fundamentals BS/MPhil Computer Science/MS Computer Science 1 Semester/Term UOS — University of Sargodha 2016
Uploaded 1 day ago · by Hifza
Download ↓
Programming Fundamentals BS 1 Semester/Term UOS — University of Sargodha 2015
Uploaded 1 day ago · by Hifza
Download ↓
Programming Fundamentals BS 1 Semester/Term UOS — University of Sargodha 2024
Uploaded 1 day ago · by Hifza
Download ↓
Programming Fundamentals M.Sc. 1st Term 1 Semester/Term UOS — University of Sargodha 2019
Uploaded 1 day ago · by Hifza
Download ↓
Paper text
UNIVERSITY OF THE PUNJAB
AD (2 Years) & BS (4 Years) Degree Program/Second Semester - Fall 2025
Paper: Programming Fundamentals
Course Code: CC-112N
Roll No.
Time: 3 Hrs. Marks: 60
THE ANSWERS MUST BE ATTEMPTED ON THE ANSWER SHEET PROVIDED
Q.1. Write the output of the following codes in your answer-sheet. Assume that the codes are free of syntax
errors (you may ignore any missing or incorrect library imports).
(6x5=30)
1. int x = 5;
bool val = (x++ == 5) && (x == 6);
cout << val << " " << x;
2. int a = 10, b = 20;
bool result = (a > b) ? a : b > 15;
cout << result;
3. int x = 0;
for (int i = 1; i < 5; i++) {
if (i % 2)
x += 1;
else
x -= 1;
}
cout << x;
4. int x = 3, y = 5;
bool result = x & y == 1;
cout << result;
5. int x = 0;
bool res = (x != 0) || (10 / x > 1);
cout << res;
6. int x = 10;
int *p = &x;
cout << *p + 2;
(3x10=30)
Q.2. Answer the following questions.
1. Write a recursive function int factorial(int n) to calculate the factorial of a number.
Demonstrate the execution of the function from main() by taking user input.
2. Write a function that takes an integer array and returns the count of even and odd numbers in the
array. Demonstrate the execution of the function from main() by taking user input.
3. Write a program to take an input n and print all prime numbers up to n.