0% found this document useful (0 votes)
46 views3 pages

CSE101-CIA II-Theory (Answer Key)

This document outlines the Second CIA Test for the CSE101 course on Problem Solving & Programming in C, scheduled for February 2021. It consists of two parts: Part A with five questions worth 10 marks and Part B with three questions worth 15 marks, covering topics such as function invocation, storage classes, variable scope, array initialization, and matrix manipulation. The document includes sample code and answers for each question, demonstrating key programming concepts.

Uploaded by

shahsham005
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)
46 views3 pages

CSE101-CIA II-Theory (Answer Key)

This document outlines the Second CIA Test for the CSE101 course on Problem Solving & Programming in C, scheduled for February 2021. It consists of two parts: Part A with five questions worth 10 marks and Part B with three questions worth 15 marks, covering topics such as function invocation, storage classes, variable scope, array initialization, and matrix manipulation. The document includes sample code and answers for each question, demonstrating key programming concepts.

Uploaded by

shahsham005
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/ 3

School of Computing

Second CIA Test – Feb 2021


Course Code: CSE101
Course Name: Problem Solving & Programming in C
Year & Programme: I Year (All Branches)– I Sem (Theory)
Duration: 45 minutes Max Marks: 25

Answer all Questions Part A 5×2=10 Marks


1. How many times get() function is invoked in the following code.
#include<stdio.h>
void get(int n)
{ if (n<1) return;
get(n-3);
get(n-5);
}
int main()
{ get(6);
}
Ans: 7 times
2. Differentiate auto and static storage classes.
Ans: explanation about Initial values, scope and life time.
3. Find the output of the following program and justify your answer.
#include<stdio.h>
int Num=100;
int main()
{ int Num=50;
printf(“Num is %d ”, Num);
return 0;}
Ans: 50. Since local and global variables are in same name, local value is preferred
over global
4. Show the significance of Null character(‘\0’) in character array.
Ans: explanation about termination character
5. When a two dimensional array is passed to a function, how are the formal argument
declarations written? Compare with one dimensional arrays.
Ans: Explanation about row and column index specification. Column index is
must in 2d.

Answer all Questions Part B 3×5=15 Marks


6. Illustrate all possible initialization methods of numeric and character values in one
dimensional array with suitable example.
Ans: Example as given below ( Minimum 5)
int a[5]={0};
int a[]={9,2,4,5,6};
int a[3]={9,2,4,5,6};
char b[]={'C','O','M','P','U','T','E','R'};
char b[9]="COMPUTER";
7. Due to malware attack, name and phone number of a customer is mixed in a character
array. Write a function to split the array into name and number. The function should
have three parameters. First parameter receives the input string(mixed character),
second (character array) stores the phone number and the third(character array) stores
the alphabets.
Sample Input values in First parameter: s2A3s4T6r8a8
After execution, Second parameter: 234688, Third parameter: sAsTra
Ans: only function is enough
void splitarray(char input[], char mobile[], char name[] )
{
int i, j=0,k=0;
for(i=0;input[i]!='\0';i++)
{
if((input[i]>='A' && input[i]<='Z') || (input[i]>='a' && input[i]<='z'))
{
name[j++]=input[i];
}
else if(input[i]>='0' && input[i]<='9')
{
mobile[k++] = input[i];
}
}
name[j]='\0';
mobile[k]='\0';
}
8. Write a program to get a two dimensional square matrix of n×n. Store the diagonal
elements of the matrix in another one dimensional array in reverse order and display.
sample: input:
1 2 3
[4 5 6]
7 8 9
Output:
[ 9 5 1]
Ans:
#include<stdio.h>
void main()
{ int mat[12][12],a[12];
int i,j,k,n;
printf("Enter the number of rows and columns for matrix\n");
scanf("%d%d",&n);
printf("Enter the elements of the matrix\n");
for(i=0;i<n;i++)
{ for(j=0;j<n;j++)
{ scanf("%d",&mat[i][j]);
}
}
k=0;
for(i=n-1;i>=0;i--)
{
{ a[k]=mat[i][i];
k++;
}
}
for(i=0;i<n;i++)
{ printf("%d ",a[i]);
}
}

You might also like