Home /PU — University of the Punjab /Programming Fundamentals

Programming Fundamentals AD/BS 2 Semester/Term PU — University of the Punjab 2025

Programming Fundamentals AD/BS 2 Semester/Term PU — University of the Punjab 2025 — page 1

Discussion

Ask a question about this paper, or help someone else with theirs. Answers are emailed to whoever asked.

Your email is only used to send you replies and occasional Ustadni updates. It is never shown publicly.

Log in to post under your name

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
  • Ayesha Mustafa· 2 days ago

    BS ZOOLOGY first semester Animal diversity ZOOL 101 - university of Punjab 2025

    0 replies Reply →
  • Abubakar· 3 days ago

    Literary criticism

    1 reply Reply →
  • Guest· 3 days ago

    this paper consists of 60 marks but now we have 35 marks paper.

    1 reply Reply →
  • Annie· 4 days ago

    Can you please tell me more past papers please because my exams are starting from next week

    1 reply Reply →
  • Ahmed· 8 days ago

    Did you provide the past papers of the science of society uos?

    1 reply Reply →

More Programming Fundamentals papers

See all

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.