0% found this document useful (0 votes)
35 views2 pages

PF Terminal

The document outlines a terminal exam for an Introduction to Computer Programming course, providing 5 questions to test students' programming skills in areas like loops, conditional statements, functions, and file input/output. Students are asked to write code to solve problems like determining the youngest of three ages, counting positive/negative/zero numbers in an array, finding the minimum and maximum of 10 numbers using a function, and storing student name and age data in a binary file using a struct.

Uploaded by

nayyabkanwal2004
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)
35 views2 pages

PF Terminal

The document outlines a terminal exam for an Introduction to Computer Programming course, providing 5 questions to test students' programming skills in areas like loops, conditional statements, functions, and file input/output. Students are asked to write code to solve problems like determining the youngest of three ages, counting positive/negative/zero numbers in an array, finding the minimum and maximum of 10 numbers using a function, and storing student name and age data in a binary file using a struct.

Uploaded by

nayyabkanwal2004
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/ 2

COMSATS University Islamabad, Islamabad Campus, ECE Dept.

Terminal Exam Spring 2022


CSC141 Introduction to Computer Programming
Class BEE 2A
Marks: 10 Time: 1/2 hour
Date: 1st July 2022 Instructor: Dr Junaid Ahmed
Name: Registration Number:

Q1. Write the output of the following programs in the box provided (CLO1-C1) (10 marks)
a)

int main () {
int i,j;
for(i=0;i<7;i++){
j=i; Output
printf("B ");
while(j<2*i){
printf("A ");
j++;
}
printf("B\n");
}
}

b)

#include <stdio.h>
int main ()
{
int i;
char arr[]={'A','B','C','D','E','F','G'};
for(i=4;i>0;i--){
switch(arr[i]){ Output
case 'A':
printf("Apple\n");
break;
case 'B':
printf("Ball\n");
break;
case 'C':
printf("Cat\n");
break;
case 'D':
printf("Doll\n");
break;
default:
printf("Not Present\n");
}
}
}
COMSATS University Islamabad (CUI)
Islamabad Campus
Department of Electrical & Computer Engineering
Terminal Exam Spring 2022
CSC141 Introduction to Computer Programming
Class BEE 2A
Marks: 40 Time: 2 hours, 30 minutes
Date: 1st July 2022 Instructor: Dr Junaid Ahmed

Q2. If the ages of Asad, Ali and Umer are input through the keyboard, write a program to
determine the youngest of the three. (CL02-C2) (5 marks)

Q3. Write a program to enter 10 numbers. At the end it should display the count of positive
numbers, negative numbers and zeros entered. (CL02-C2) (10 marks)

Q4. Write a function that calculates minimum and maximum of 10 numbers; this function can have
maximum 4 parameters. Write a program that inputs 10 numbers, finds their minimum and
maximum using your function and displays the result on screen.
(CLO3-C3) (10 Marks)

Q5. Write a program that takes the number of students in a class then inputs their data (name and
age) using the data structure given below and saves the data in a file names “class.bin”.
Hint: Dynamic memory allocation is required.
struct data{
char name[30];
int age; (CLO3-C3) (15 + 5 (bonus) Marks)
};

You might also like