0% found this document useful (0 votes)
182 views6 pages

PF - Final Question Fall 2023

Uploaded by

kanroji990
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)
182 views6 pages

PF - Final Question Fall 2023

Uploaded by

kanroji990
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/ 6

Question Moderation Form for Final Examination

Premier University
Department of Computer Science and Engineering
Course Code: CSE 1113 Course Title: Programming Fundamentals
st
Session: Fall 2023 Semester: 1 Course Teacher: MH, AIH, MHN

Section 1: To be completed by the Course Teacher Section 2: To be completed by


Moderator (s)
No. Course Learning Exam questions Level of Question (s) Comments
Outcome Addressing to Bloom’s Addresses the
CLO(s) Taxonomy CLO
satisfactorily
(Yes/No/ NA)
1. Describe basic programming 4(a), 6(a) C2
approaches with data types, input and
output operations.
2. Write the syntax of the conditional 1(a), 2(a), 3(a), 5(a), 4(b) C3
statements for solving a specific
problem.
3. Write the syntax of the looping 1(b), 2(b), 3(b), 5(b), 6(b) C3
statements for solving a specific
problem
4. Prepare solutions of real world 1(c), 2(c), 3(c), 4(c), 5(c), C4
problems using user-defined functions 6(c)
and data types.

Checked by: Date:


Premier University
Department of Computer Science & Engineering
1st Semester Final Examination, February 2024
Course Code: CSE 1113 Course Title: Programming Fundamentals
Time: 3 Hours Full Marks: 40

NB: Answer any of four (4) from the following six (6) questions.
Each question carries equal marks.

Q1. a. Write a one-line statement using the conditional operator (?:) to find the 2 CO2
maximum value of two numbers a and b.
b. Write down the output of the following C program. 3 CO3
#include <stdio.h>
int main()
{
int i,j,k;
for(i=0, j=0, k=0; i<3; i++)
{
printf("%d %d %d\n",i, j, k);
j+=2;
k+=3;
}
}
c. Write a C program to find the difference between the maximum and 5 CO4
minimum elements of an array.
Sample input:
Number of elements: 4
Elements are: 45 67 89 34
Sample Output:
The difference is: 55

Q2. a. A year y is called a beautiful year if one of the following conditions 2 CO2
hold:
(i) y is divisible by 50.
(ii) y is divisible by 5 but not divisible by 10
Based on the above rules fill out the following condition marked with "???"
symbol to correctly perform the beautiful year testing:
if( ??? )
{
printf("A beautiful year!");
}
else
{
printf("Not a beautiful year!"); }
b. Write down the output of the following C program. 3 CO3
#include<stdio.h>
void main ()
{
int i;
for(i=0;i<10;i++)
{
i = 20;
printf("%d ",i);
}
}
c. Write a C program that takes a string as input and prints the difference 5 CO4
between the number of consonants and vowels.
Sample Input: lumbricoidus Sample Output: 2
Hint: Here the number of consonants is 7 and the number of vowels is 5.
Therefore, the difference between them is 2.

Q3. a. Rewrite the following code snippet using IF-ELSEIF ladder: 2 CO2
char op;
float num1, num2, result=0.0;
scanf("%f %c %f", &num1, &op, &num2);
switch(op){
case '+': result = num1 + num2;
break;
case '-': result = num1 - num2;
break;
default: printf("Invalid operator");}
printf("%.2f %c %.2f = %.2f", num1, op, num2, result);
}
b. The given program is written using a for loop. Rewrite this program using 3 CO3
a while loop instead of a for loop.

#include <stdio.h>
int main() {
int i, sum = 0;
for (i = 1; i <= 10; i++) {
sum += i;
if (i==5)
break;
}
printf("Sum = %d", sum);
return 0;
}
c. Write a C program to take an integer as input and check whether the number 5 CO4
is prime or not using a function named Isprime().
Hint: A prime number is a number that has only two factors, that is, 1 and
the number itself. For example, 2, 3, 5, 7 are prime numbers.
Q4. a. Write a C program to read 10 integer numbers and save in num.txt file. 2 CO1

b. A company will give bonus to its employees based on the gender and total 3 CO2
experience of working in this company:
1 represents the gender of male employees and 0 for the female employees.
If a male employee has more than 10 years working experience, he will
receive 10% bonus. However, the female employees will receive 12% bonus
if they have more than 10 years working experience. All the employees will
be given 5% bonus whatever the gender is if they have less than or equal 10
years of experience. The bonus will be given based on the basic salary.
Now write a C program to calculate the bonus amount where the gender,
working experience, and basic salary will be given.
c. Write the Output of the following program. Rewrite the program with a 2+3 CO4
union (The output should be the same).
#include <stdio.h>
struct student {
int id;
float marks;
};

int main()
{
struct student st1;
st1.id = 12;
st1.marks = 75;
printf("student ID: %d\n",st1.id);
printf("marks: %.2f",st1.marks);
return 0;
}

Q5. a. Write down the output of the following C code. 2 CO2


int day = 4;
switch (day) {
case 6:
printf(“Today is Saturday”);
break;
case 7:
printf(“Today is Sunday”);
break;
default:
printf(“Looking forward to the Weekend”);
}
b. Write down the output of the following C program. 3 CO3
#include<stdio.h>;
int main(){
int i,j,x;
for(i=0;i<5;i++){
for(j=0;j<5;j++){
x=2*i-j+1;
if(x%3==0)
printf("%d\n",x);
else
break; }
}
printf("x=%d",x);
return 0;
}
c. Write a C program to check whether two matrices are equal or not. 5 CO4
Sample Input:
Matrix A
123
456
789
Matrix B
123
466
789
Sample Output:
Two matrices are not equal.

Q6. a. Write down the modes for opening a file. CO1 2

b. Write down a C program that will generate the following triangle of numbers CO3 3
(using loops).
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
c. Write a C program to count the number of even and odd integers stored in an CO4 5
array. Your program should read n integers from the user.
Sample input: 5
10 15 20 25 30
Sample Output: 3 2

You might also like