CLO 1 Question # 1 (6 Marks) : CLO 1 Question # 4 6 Marks)

You might also like

You are on page 1of 1

Programming Fundamentals MID Term University of Engineering and Technology, KSK Campus Maximum Marks 30

Time Allowed 60 min Name: Reg. # 201 – EE – Answer Sheet # .


CLO 1  Question # 1 (6 Marks): Print the output of following CLO 1  Question # 4 (6 Marks): Write the output of the following
program: code.
#include <stdio.h> #include <stdio.h>
/* function declaration */ main(){
void func(void); int a = 10;
static int count = 5; /* global variable */ int b = 2;
main(){ b = a++ + ++b;
while(count--) printf(“a is %d and b is %d\n”, a, b); //2 marks
func(); a = --b * --a;
} printf(“a is %d and b is %d\n”, a, b); //4 marks
/* function definition */ }
void func( void ) {

static int i = 5; /* local static variable */


i++;
printf("i is %d and count is %d\n", i, count);
}

CLO 2  Question # 4 (8 marks): Write a recursive function


power(base, exponent) that when invoked returns:
baseexponent. For example power(3,4) = 3*3*3*3. Assume
exponent is an integer greater than or equal to 1 and base
can be in fraction. Also show the function call of this power
function in main().
Main function is of two marks and functions definition is of
6 marks.

CLO 3  Question # 2 (10 marks): A palindrome is a string that


is spelled the same way, backward and forward. Some
examples of palindrome are: “radar”, “able was i ere i saw
elba”, and if you ignore blanks, “a man a plan a canal
panama”. Write a function testPalindrome that returns 1 if
the string stored in an array is a palindrome and 0 otherwise.
The function should ignore spaces in the string.
Function definition is of 8 marks, 3 of which is to detect
spaces. Main function is of 2 marks.

You might also like