Cse 1111
Cse 1111
IMPORTANT GUIDELINES:
2. The student will attempt one question on each page which will contain his/her name,
registration number, roll number, section and signature.[Every page should have these
parameters(Handwritten)]
Section: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Student Name: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Registration Number: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Roll Number: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Signature: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
iii) Have a look at the following piece of code and state the output.
#include <stdio.h>
int main(void)
{
int i = 10;
if(i > i)
printf("\nHi");
else
printf(“\nBye");
return 0;
}
v) Have a look at the following piece of code and state the output.
#include <stdio.h>
int main(void)
{
for(;;);
printf("\nHi");
return 0;
}
Q2. Write a program which has a function to which a string is passed and the program should be
capable of counting the vowels in the string. [5]
Input:
“hello”
Output:
2
Q3. Given a 4 x 4 matrix representing a chessboard where ‘X’ indicates the presence of a pawn
which can move one step in the direction [up, down, left, right] print out the indices where it is
safe to place your pawn so that it is not in the range of the other pawns. [10]
Sample Run:
Input:
...X
X..X
.XXX
....
Output:
Safe indices are:
0,1
3,0
Q4. Andrew likes the topic of strings a lot and tries to solve as many problems as he can on this
topic. He came across a problem in which he was given a string and he was asked to print all
substrings of length 1, 2 and 3 from it. Please use a function which receives the string passed as a
parameter and print the substrings. [5]
Sample Run:
Input:
abcd
Output:
All substrings of length 1:
abcd
All substrings of length 2:
ab bc cd
All substrings of length 3:
abc bcd
Q5. Write a program which has a function to which we pass two strings represented as pointers.
The function should be able to remove all the vowels from both the strings and concatenate them
together. [5]
Sample Input :
First String : “abdef”
Second String : “ghijk”
Sample Output :
“bdfghjk”
Note : The second string should be concatenated at the end of the first string.