Pps Unit Wise Questions

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

Page No.

PRATICE QUESTIONS
SUBJECT: PROGRAMMIN FOR PROBLEM SOLVING

1 MARKS QUESTIONS
FILL IN THE BLANKS
UNIT-I (basics, if..else, switch)
1) Find the output:
main() [CO1/PO2]
{ int x=5;
printf(“%d”,printf(“%d%d”,x,x)); }

options:
a) 5 5 5
b) 5 5 1
c) 5 x x
d) 5 5 2

2) Find the output: [CO1/PO2]


main()
{ printf(“%d”,sizeof(“hasini”); }
options:
a) 5
b) hasini
c) 6
d) 7

3) The given statement x=x+5; Its equivalent statement using += operator is: [CO1/PO2]
Options:
a) x+=5;
b) x+5;
c) x=5;
d) x= =5;

4) In C language, which library function checks whether the input value of the argument is an
alphabet or not. [CO1/PO2]
Options:
a) alpha()
b) isalpha()
c) alphabet()
d) chkalpha()

5) Which statement allows us to define a symbol for a constant value in a c program:


Options: [CO1/PO2]
a) #define
b) #if
c) #include
d) int

6) The format specifier for long int and float are:


Options: [CO1/PO2]
a) %ld and %f
b) %long and %f
c) %i and %f
d) None of these

7) Find the output for below Given code: [CO1/PO2]


int x=20, y=30,z;
Page No. 2

z=(x<y)+10;
printf(“%d”,z);
options:
a) 10
b) 1
c) 11
d) error

8) Given: printf(“abhi\bla\b\byash”); [CO1/PO2]


The output is:
Options:
a) abhilayash
b) abhlayash
c) abhyash
d) abhi\bla\b\byash

9) Given: [CO1/PO2]
int x,y,z,q;
x=10; y=5; z=3;
q=x>y>z;
printf(“%d”,q);
the output is :
options:
a) 1
b) 0
c) 10
d) 5

10) Given: [CO1/PO2]


int a,b,c;
a=10, b=10, c=10;
if(a+b/c) printf(“true”);
else printf(“false”);
the output is :
options:
a) true
b) 11
c) false
d) 10+10/10

11) The format identifier ‘%i’ is also used for _____ data type? [CO1/PO2]
options
a) char
b) int
c) float
d) double

12) Which of the following is not a valid C variable name? [CO1/PO2]


a) int number;
b) float rate;
c) int variable_count;
d) int $main;

13) Find the output [CO1/PO2]


#include<stdio.h>
int main ()
{
int x = 10;
float y = 10.0;
if(x = = y)
printf("x and y are equal");
Page No. 3

else
printf("x and y are not equal");
return 0;
}
Options:
a) x and y are equal
b) Compile Error
c) Run Time Error
d) x and y are not equal

14) Find the output [CO1/PO3]


#include<stdio.h>
int main()
{
int a = 100, b = 200, c = 300;
if(!a >= 500)
b = 300;
c = 400;
printf("%d,%d,%d",a, b, c);
return 0;
}

Options:
a) 100,300,400
b) 100,200,400
c) 500,200,400
d) 100,300,300

15) Find the output from options given, when we execute the below statements:[CO1/PO2]
int a,b;
float d;
a=10; b=5;
d=(float)b/a;
printf(“ %d, %d, %f”,a,b,d);

options:
a) 10, 5, 0
b) Error
c) 10, 5, 0.500000
d) None of the above

16) what will be the output from below options? [CO1/PO2]


#include<stdio.h>
#define int char
int main()
{ int i=65;
printf(“size =%d”,sizeof(i));
return 0;
}

Options:
a) size =1
b) size =2
c) size =4
d) Error

17) What will be the output from below options? [CO1/PO2]


#define SUM 10+10*10/10
void main()
{ int a;
Page No. 4

a=SUM/SUM;
printf(“%d”,a);
}

Options:
a) 1
b) 21
c) 20
d) Error

18) Find the output from below options when we execute the below statements: [CO1/PO2]
int a,b,c,d,e;
a=10; b=20; c=15; d=25;
e=(a>b)? c : d ;
e=(e>a)? 1 : 0;
printf(“%d”,e);

options:
a) 0
b) 1
c) false
d) true

19) Find the output of below statement in the given options: [CO1/PO2]
printf(“santosh\b\b\bilata\nare you\?”);

options:
a) Santosh ilata
are you?
b) santilata
are you?
c) Santosh ilata
are you”
d) santilata
are you”

20) What will be the output of the program? [CO1/PO2]


#include<stdio.h>
int main()
{
int y=128;
const int x=y;
printf("%d\n", x);
return 0;
}

Options:
a) 128
b) Garbage value
c) Error
d) 0

21) what will be the output? [CO1/PO2]

#include <stdio.h>
#define EVEN 0
#define ODD 1
int main()
{
int i = 3;
switch (i & 1)
Page No. 5

{
case EVEN: printf("Even");
break;
case ODD: printf("Odd");
break;
default: printf("Default");
}
return 0;
}

Options:
a) Even
b) Odd
c) Default
d) compile-time error

UNIT-II (loop, 1D and 2D array)

1) Repeated execution of a set of statements for a specific number of times is called:


Options: [CO2/PO1]
a) Looping
b) Sequential
c) Branching
d) selection

2) The keyword used to transfer control from a function back to the calling function is:
Options: [CO2/PO1]
a) return
b) exit()
c) break
d) continue

3) A set of consecutive memory locations having homogeneous elements is called:


Options: [CO2/PO1]
a) Structure
b) Array
c) Pointer
d) Function

4) What is the output of this C code? [CO2/PO1]


void main()
{
while(0)
printf(“ In while Loop “);
printf(“After While Loop”);
}

Options:
a) In while loop after while loop
b) After while loop
c) Compile time error
d) Infinite loop

5) what will be the output ? [CO2/PO1]


main()
{
while(!(printf(“hi”)));
}

Options:
Page No. 6

a) infinite loop
b) hi
c) error
d) none of the above

6) what will be the output ? [CO2/PO1]


void main( )
{ printf(“%s”, “C Marathon”+2); }

Options:
a) C MarathonC Marathon
b) E Marathon
c) Marathon
d) error

7) In C, if you pass an array as an argument to a function, what actually gets passed?


Options: [CO2/PO1]
a) Value of elements in array
b) First element of the array
c) Base address of the array
d) Address of the last element of array

8) Examine the following: [CO2/PO1]


double[ ][ ] values =
{ {1.2, 9.0, 3.2},
{9.2, 0.5, 1.5, -1.2},
{7.3, 7.9, 4.8} } ;
what is in values[2][1] ?
options:
a) 7.3
b) 7.9
c) 9.2
d) There is no such array element

9) Given the following: [CO2/PO1]


double [ ][ ] a ={ {1.2, 9.0},{9.2, 0.5, 0.0},{7.3, 7.9, 1.2, 3.9} } ;
What is the value of a[0][1]?
Options:
a) 2
b) 3
c) 4
d) 9

10) What will happen if in a C program you assign a value to an array element whose subscript
exceeds the size of array?
Options: [CO2/PO1]
a) The element will be set to 0.
b) The compiler would report an error.
c) The program may crash if some important data gets overwritten.
d) The array size would appropriately grow.

UNIT-III (string handling, function)

1) If the two strings are identical, then strcmp() function returns: [CO3/PO1]
Options:
a) 0
b) 1
c) Equal
d) Identical

2) The use of strrev() function is: [CO3/PO1]


Page No. 7

Options:
a) To reverse a string
b) To copy a string
c) To print a string
d) To join a string with other

3) What is the output of this C code? [CO3/PO1]

void foo( );
int main( )
{
foo( );
return 0;
}
void foo( )
{
printf("2 ");
}

Options:
a) 2
b) Compile time error
c) Depends on the compiler
d) Depends on the standard

4) What is the output of this C code? [CO3/PO2]


void m()
{
printf("hi");
}
void main()
{
m();
}

Options:
a) hi
b) run time error
c) Nothing print
d) It varies

5) What is the default return type of a user defined function. [CO3/PO1]


Options:
a) int
b) char
c) float
d) double

6) find the output. [CO3/PO2]


void main()
{
char str[90];
str[90]=”string”;
puts(str)
}
Options:
a) String
b) NULL
c) error
d) none of these
Page No. 8

7) what is prototype of a function in C [CO3/PO2]


options:
a) It is the return type of a function
b) It is the return data of the function
c) It is declaration of a function
d) It is a data type

8) Any type of modification on the parameter inside the function will reflect in actual variable
value can be related to:
Options: [CO3/PO2]
a) call by value
b) call by reference
c) both of above
d) none of above

9) What is the output of the following program? [CO3/PO2]


#include< stdio.h>
int main()
{
static int a = 3;
printf(“%d”, a --);
return 0;
}

Options:
a) 0
b) 1
c) 2
d) 3

10) Which of the following statement are correct? [CO3/PO2]

I) The maximum value a variable can hold depends upon its storage class.
II) By default all variables enjoy a static storage class.

options:
a) Only I is correct
b) Only II is correct
c) Both I & II are correct
d) Both I & II are incorrect

11) What will be the output of the following program? [CO3/PO2]

#include< stdio.h>
void fun()
{
fun();
return 0;
}
void fun()
{
auto int i = 1;
register char a = ‘D’;
static int p = 0;
printf(“%d %d %d”, i, a, p);
}
Page No. 9

options
a) 1 D 0
b) 1 0 0
c) 0 D 1
d) 1 68 0

12) What will be the output of the following program? [CO3/PO2]

#include < stdio.h>


static int y = 1;
int main()
{
static int z;
printf(“%d %d”, y, z);
return 0;
}

Options:
a) Garbage value
b) 0 0
c) 1 0
d) 1 1

13) What will be the storage class of variable I in the code written below? [CO3/PO3]

#include< stdio.h>
int main()
{
int i = 10;
printf(“%d”, i);
return 0;
}

Options:
a) Automatic storage class
b) Extern storage class
c) Static storage class
d) Register storage class

14) Where will the space be allocated for an automatic storage class variable? [CO3/PO2]

Options:
a) In CPU register
b) In memory as well as in CPU register
c) In memory
d) On disk

15) What will be the output of the following code? [CO3/PO2]

#include< stdio.h>
int main()
{
int a=1;
static char j = ‘E’;
printf(“%c”, ++j);
printf(“%d”, --a);
return 0;
}

Options:
a) E 2
Page No. 10

b) F 1
c) F Garbage
d) F 0

UNIT-IV(pointer, structure, typedef)

1) By default a function returns a value of type [CO4/PO1]


Options:
a) int
b) char
c) void
d) None of these

2) In function free(p), p is a: [CO4/PO1]


Options:
a) int
b) Pointer returned by malloc()
c) Pointer returned by calloc()
d) Both b & c

3) The memory allocation function which modifies the previous allocated space is:
Options: [CO4/PO1]
a)calloc()
b)malloc()
c)free()
d)realloc()

4) What is the output of the following: [CO4/PO3]


void main( )
{ char *p=”FHDS”;
while(*p!=’\0’)
{ printf(“%c”,*p+1);
p++;
}
}
Options:
a) FHDS
b) GIET
c) SDHF
d) none of the above

5) What is the output of the following: [CO4/PO1]


main( )
{ char *a=”Hello”;
char *p=”World”;
strcpy(a,p);
printf(“%s”,a);
}

Options:
a) Hello
b) HelloWorld
c) World
d) None of these

6) Structures can be used [CO4/PO1]

Options:
a) to hold different data types
Page No. 11

b) have pointers to structures


c) to assign to one another
d) all of above

7) Difference between calloc() and malloc() [CO4/PO1]

Options:
a) calloc() takes a single argument while malloc() needs two arguments
b) malloc() takes a single argument while calloc() needs two arguments
c) malloc() initializes the allocated memory to ZERO
d) calloc() initializes the allocated memory to NULL

8) calloc() belongs to which library [CO4/PO1]

options:
a) stdlib.h
b) malloc.h
c) calloc.h
d) None of above

9)What will be the output of the program ? [CO4/PO1]

#include<stdio.h>
int main()
{
char str[] = "Nagpur";
str[0]='K';
printf("%s, ", str);
str = "Kanpur";
printf("%s", str+1);
return 0;
}

Options:
a) Kagpur,Kanpur
b) Nagpur,Kanpur
c) Kagpur,anpur
d) error

10) What is the output of this C code? [CO4/PO1]

typedef struct p
{
int x, y;
}k;

int main()
{
struct p q = {1, 2};
k = p;
printf("%d\n", k.x);
}

Options:
a) Compile time error
b) 1
c)0
d) Depends on the standard
Page No. 12

11) typedef declaration: [CO4/PO1]

options:
a) Does not create a new type
b) It merely adds a new name for some existing type.
c) Both a & b
d) None of the mentioned

12)Which of the following cannot be a structure member? [CO4/PO1]

options:
a) Another structure
b) Function
c) Array
d) None of the mentioned

2 MARKS SHORT QUESTIONS


UNIT-I (basics, if..else, switch)

1) What are the rules for naming an identifier ? [CO1/PO1]


2) Write an example on usage of conditional operator. [CO1/PO2]
3) What is type casting. Write with a suitable example. [CO1/PO2]
4) What is the difference between && and &. [CO1/PO1]
5) Write down the syntax and example on statements: printf, scanf [CO1/PO2]
6) What is the use of getchar() and putchar(). [CO1/PO1]
7) State the role of break statement in switch..case control structure. [CO1/PO1]
8) How does bitwise operator XOR works? [CO1/PO2]
9) Identify valid and invalid statements below: [CO1/PO2]
int a+b;
char long;
int x,y,z,p,q,w,e,r,t,y,u,i;
float QWE_TY;

10) Find the output when we execute the below statements: [CO1/PO2]
int x,y,z,a;
x=30;y=20;z=10;
a=x>y>z;
printf(“%d”,a);
11) Find the output when we execute the below statements: [CO1/PO2]
int y,z,a;
y=3; z=4;
a=y*=z/=2;
printf(“%d”,a);
12) Find the output when we execute the below statements: [CO1/PO2]
int a,b;
a=20;
b=a>>1;
printf(“%d %d”,a,b);
13) Find the output when we execute the below statements: [CO1/PO3]
int a,b,c,e;
a=10; b=20; c=30;
e=(a>b)|| (b<c) && (c==50);
printf (“%d”,e);
14) Find the output when we execute the below statements: [CO1/PO3]
int a,b,c,d,e;
a=100; b=50; c=30; d=0;
e=(a>=b>=c>=d);
Page No. 13

printf(“%d”,e);
15) what will be the output and why? [CO1/PO3]
#include<stdio.h>
void main()
{ int x,y; x=10; y=10;
if(x/x%x) printf(“It is summer”);
else printf(“it is rainy”);
}
16) what will be the output and why? [CO1/PO3]
#include<stdio.h>
void main()
{ int s;
s=(0= =0) ? 0 : 1 ;
if(!s) printf(“my land is beautiful”);
else printf(“my country is great”);
}

17) what will be the output and why? [CO1/PO3]


main()
{ int k=-2, j=4;
switch(k/=j/k)
{ default: printf(“default”);
case 0: printf(“zero”);
case 1: printf(“one”);
case 2: printf(“two”);
}
}
18) what will be the output and why? [CO1/PO2]
#include<stdio.h>
void main()
{ float a=9.876;
switch(a)
{ case 9: printf(“CATHY”); break;
case 9.8: printf(“MADDY”); break;
case 9.876: printf(“NANCY”); break;
default: printf(“SUNNY”);
}
}
19) what will be the output and why? [CO1/PO2]
#include <stdio.h>
#define A 1 + 2
#define B 3 + 4
int main()
{
int var = A * B;
printf("%d\n", var);
}

20) #include <stdio.h> [CO1/PO2]


int main()
{
if (printf("geeks") != 5)
{}
else
printf("geeksforgeeks");
return 0;
}

UNIT-II(loop controls, arrays)


1) State the difference between break and continue while using in a loop control statements.
Page No. 14

[CO2/PO2]
2) State the syntax of do..while loop? [CO2/PO1]
3) What is an array ? What are the types of it? How to initialize values to a 1D array during its
declaration. [CO2/PO2]
4) Write down the syntax and example of for statement. [CO2/PO2]
5) What is an infinite loop? [CO2/PO2]
6) How to interact with all the elements of a matrix using simple loop control statements?
[CO2/PO2]
7) State the difference between while and do..while [CO2/PO2]
8) Differentiate between a for loop and a while loop? What are it uses? [CO2/PO2]
9) Why is it necessary to give the size of an array in an array declaration? [CO2/PO1]
10) Define Conditional control structure and its types [CO2/PO1]
11) What is the use of break statement [CO2/PO1]
12) What is continue statement and why we use it ? [CO2/PO2]
13) Give out the syntax of for loop with an example. [CO2/PO2]
14) what will be the output and why? [CO2/PO3]
main()
{ int i,j;

i=0; j=400;
while(i<j) --j; ++i;
printf(“%d”, i – j );
}
15) what will be the output and why? [CO2/PO3]
main()
{ int K;
for(K=0; K<printf(“HELLO”); K++)
printf(“%d”,K);
}
16) what will be the output and why? [CO2/PO2]
main()
{ printf(“%c”, “abcdef”[4]); }

UNIT-III(character handling, functions, storage classes.)

1) State the difference between recursive and iterative process. [CO3/PO2]


2) What is the role of return statement in a function ? Can we write a function which can return
more than one value using return statement? [CO3/PO2]
3) Write the syntax and example on function prototype declaration. State the difference between
formal parameters and actual parameters. [CO3/PO2]
4) Explain about the characteristics of storage classes: static, register. [CO3/PO2]
5) What is nesting of functions? [CO3/PO1]
6) What is the difference between strcmp() and strncmp() functions? [CO3/PO2]
7) Explain what is call by reference? [CO3/PO3]
8) What is storage class. What are the different storage classes in C? [CO3/PO2]
9) What is the difference between Strings and Arrays? [CO3/PO2]
10) What is a function ? How to define an UDF ? [CO3/PO1]
11) What are built in functions ? [CO3/PO1]
12) Difference between formal argument and actual argument ? [CO3/PO2]
13) What is register variable? Why we use it? [CO3/PO1]
14) Distinguish local variable and global variable [CO3/PO2]
15) Define static variable? how it differs automatic variables? [CO3/PO2]
16) Define Function prototype ? give out its syntax? [CO3/PO1]
17) what is storage classes ? list out the different types? [CO3/PO1]
18) Find output:
main( ) [CO3/PO1]
{ int a=15, b=19;
int x=sum(a,b);
printf(“%d”,x); }
Page No. 15

int sum(int x, int y)


{ int c=x+y;
return(x);
return(y);
}
19) Find output: [CO3/PO1]
main( )
{ static int a=1;
printf(“%d”,a++);
if(a<=4)
main( );
}

UNIT-IV(pointer, structure ,typedef )


1) What is a pointer ? How to declare a pointer? Explain how a pointer works, with a suitable
example. [CO4/PO2]
2) Differentiate between call by value and call by address in function calling. [CO4/PO3]
3) State the difference between static memory allocation and dynamic memory allocation.
[CO4/PO2]
4) State the syntactical difference between malloc( ) and calloc( ). [CO4/PO1]
5) What is the advantage of a character pointer over character array? [CO4/PO3]
6) What the difference between structure and array. [CO4/PO1]
7) What is bit field in structure? [CO4/PO1]
8) What is the typedef declaration? Give suitable example. [CO4/PO2]
9) Write an example on nested structure. [CO4/PO1]
10) When to user -> (arrow) operator. [CO4/PO1]

11) Find Output: [CO4/PO3]


main( )
{ int x[5]={15,20,7,5,99};
printf(“%d %d %d”,*(&x[3]), x[3], 3[x]);
}

12) Find Output: [CO4/PO3]


main( )
{ char *ptr;
ptr=”GUNUPUR”;
printf(“%c”,*(&(*ptr)));
}

13) Find Output: [CO4/PO3]


#include<stdio.h>
int x=-10, y=20;
void main( )
{ iner(x,&y);
printf(“x=%d, y=%d”,x,y);
}
void iner(int a, int *p)
{ int x=0;
a=a+1;
*p=*p+1;
printf(“a=%d, x=%d”,a,x);
}

14) Find Output: [CO4/PO3]


int qq(int a, int b)
{ return a*b; }
void main( )
{ int i=5,j=6,c;
c=qq(qq(i++,++j),qq(++i,j++));
Page No. 16

printf(“%d”,c);
}

15) Find Output: [CO4/PO3]


typedef struct s1 {
float a,b;
struct g1 {
double c,d;
};
} new1;
int main()
{
cout << sizeof(new1) << endl;
return 0;
}

LONG QUESTIONS:

UNIT-I (basics, if..else, switch)


1)
a. Write down the syntax of else if ladder and switch..case and then state the difference
between them. Write a program to find greatest among 3 numbers using switch..case
[CO1/PO2]
b. What is an algorithm and flowchart? Draw the flowchart and write algorithm for
accepting a number and check whether it is prime or not. [CO1/PO3]
2)
a. Write an algorithm and draw flowchart to input a number and check whether it is
Armstrong or not. [CO1/PO3]
b. Explain the use of each of the following: [CO1/PO1]
i. /* and */
ii. Header files
iii. Basic Data types
3)
a. Explain the following & illustrate each of them with an example. [CO1/PO2]
i. Increment & Decrement operator.
ii. Conditional operator.
iii. Bitwise operator.
b. Elaborate the usage of : [CO1/PO2]
i. format specifiers
ii. escape sequence characters
iii. symbolic constants in programming?
4)
a. What are the different types of control statements available 'C'. Explain each of them
with example? [CO1/PO2]
b. Explain switch – case statement. Design a simple calculator for performing: arithmetic
and relational operations. [CO1/PO3]

5)
a. Explain briefly about the basic structure of a c program. [CO1/PO2]
b. Write down the syntax of else if ladder. State the difference between switch..case and
else if ladder. Write a program to input 3 unequal numbers and find the greatest using
switch..case. [CO1/PO2]
6)
a. Write down the syntax of else..if ladder. Write a program to input 3 co-efficient
values and find the real roots of a quadratic equation using else if ladder. [CO1/PO2]
b. Write down the syntax of conditional operator and Write a program to find the
greatest among 5 integers using conditional operators. [CO1/PO2]
7)
a. Write a program to accept arithmetic operator and two operands. Find the result as
per the operator symbol entered using else if ladder. [CO1/PO2]
Page No. 17

b. Write a program to input 4 unequal numbers and find the greatest using else if ladder.
[CO1/PO2]

8)
a. Write a program input a lowercase character and test it for vowel or not using
switch..case. [CO1/PO2]
b. Write a program to display weekday as per the digit given within(1 to 7), i.e: 1 –
Sunday, 2- Monday, 3-Tuesday etc. Use switch..case [CO1/PO2]

UNIT-II(loop, 1D and 2D array)


1)
a. Write a program to input values into two matrices A(3x4), B(4x3). Perform matrix
multiplication and display the resultant matrix. [CO2/PO3]
b. Write a program to apply binary search on an array having elements in sorted order.
Explain how it is different from linear search. [CO2/PO3]
2)
a. Write a program to accept 10 numbers in to an array and sort it using insertion sort in
ascending order. [CO2/PO3]
b. Explain how the Bubble sort works? Write a program to apply this method to sort a
string in descending order. [CO2/PO3]
3)
a. Write a program to display the factorial of all the numbers of series: 1,3,5,…21
[CO2/PO3]
b. Write a program to check how many prime numbers and perfect numbers exist within
1to 100. [CO2/PO3]
4)
a. What is an array and its types. Explain how to initialize values into an array? Write a
program to interact with elements of 1D array and 2D array. [CO2/PO3]

b. Write down the syntax of while, do..while and for statement. State the difference
between while and do..while using suitable example. [CO2/PO3]
5)
a. Explain how an array can be declared and initialized? Write a suitable program to
interact with 1-D array elements. [CO2/PO2]
b. Briefly explain the syntax of while, do..while and for statements using a suitable
example. [CO2/PO2]

6)
a. Write down the difference between Entry Controlled vs. Exit Control loop with
suitable example. Write a program to print Alphabets from ‘A’ to ‘Z’ using while.
[CO2/PO2]
b. Write a program to input a positive integer and its equivalent binary number using
loop. [CO2/PO2]
7)
a. Write a program to input elements into 4 × 4 matrix and find the principal diagonal.
[CO2/PO2]
b. Write a program to accept a number test whether it is palindrome or not. [CO2/PO3]
8)
a. Write a program to find the greatest common divisor of given two positive integers.
[CO2/PO2]
b. Write a program to input a positive number and test whether it is Armstrong number
or not. [CO2/PO3]

9)
a. Write a program to input a number and check whether it is prime or not. [CO2/PO3]
b. Write a program to input values into a 4X4 matrix and find the sum of its diagonal
elements. [CO2/PO2]
10)
a. Write a program print a series of numbers 1,4,9,16,25……n2 where n is given as
input. [CO2/PO3]
Page No. 18

b. Write a program to accept 10 numbers in to an array and sort it in ascending order


[CO2/PO3]
11)
a. Write a program to accept a string in to a character array and sort it’s alphabets in
ascending order. [CO2/PO3]
b. Write a program generate pyramid given below: [CO2/PO3]
1
1 2 3
1 2 3 4 5
1 2 3 4 5 6 7
12)
a. Write a program generate pyramid given below: [CO2/PO3]
A
A B C
A B C D E
A B C D E F G

b. Write a program to input values into a 4X4 matrix and display the transpose of it.
[CO2/PO2]

13)
a. Write a program to print the pyramid [CO2/PO3]
5
56
567
5678
56789

b. Write a program to find the factorial of a given +ve number using while. [CO2/PO3]

UNIT-III (character handling, functions, storage classes.)


1)
a. Write a program to create an UDF which accepts an integer array and counts how
many prime numbers exist in the array. [CO3/PO3]
b. Write the syntax and explain on functions: strcmp(), strrev(), strcpy() [CO3/PO2]

2)
a. What are the necessary statements for writing an UDF? What is the difference
between actual parameters and formal parameters? Explain with a suitable example.
[CO3/PO2]
b. What are the function categories ? Explain all the categories with suitable examples.
[CO3/PO2]
3)
a. What is a recursive function? How it is different from a iterative function? Write a
program to find the factorial of a given number using recursive function and also
using iterative function. [CO3/PO3]
b. Briefly explain all the storage classes and their characteristics. [CO3/PO2]
4)
a. Write a program to accept the string and count the number of vowels present in the
string. [CO3/PO3]
b. Write a program to test a string is palindrome or not without using string handling
functions. [CO3/PO2]
5)
a. Write a C program which contains three UDF’s namely add(), subtract() and
multiply(). Each function accepts two integers as their arguments and calculate and
return the results [CO2/PO3]
b. Write a program to accept two strings and check whether they are equal or not using
UDF. [CO3/PO2]
6)
a. Write a program to input values into two 4X4 matrices. Create an UDF which accepts
the two matrices and perform matrix addition. [CO3/PO2]
Page No. 19

b. Write a program to create a recursive function to test a string is palindrome or not.


[CO3/PO3]
7)
a. Write a program to input two numbers and find the GCD of them using a recursive
function. [CO3/PO3]
b. Write a program to generate Fibonacci series of N numbers using a recursive
function. [CO3/PO3]
8)
a. Write down the difference between the followings with suitable example for each :
(ii)while vs. do..while [CO3/PO3]
(iii)call by value vs call by address
b. How to define an UDF? What is the difference between actual parameters and formal
parameters? What is the role of return statement? Write a program to input 5 numbers
and find largest, smallest using UDF. [CO3/PO2]
9)
a. Write a program to find GCD of two integers using a recursive function. [CO3/PO3]
b. Briefly explain all the storage classes and their characteristics. State the difference
between auto and static with an example. [CO3/PO3]

UNIT-IV (pointer, structure , typedef)


1)
a. What is a pointer ? How a pointer can be used to navigate between memory locations
of an array? Explain briefly with a suitable example. [CO4/PO2]
b. What is the advantage of a character pointer over a character array ? Explain the
terms array of pointers, pointe to pointer. [CO4/PO2]
2)
a. Explain the syntax and example on malloc(), calloc(). Write a program to allocate N
integer memory , store the numbers, find the average of them using dynamic memory
allocation. [CO4/PO3]
b. Write short notes on any 3 out of 5 [CO4/PO1]
i. Dynamic memory allocation
ii. String handling
iii. Uses of Pointers
iv. Nested loops
3)
a. Write a program to input two numbers and using call by address concept find LCM
and GCD. [CO4/PO3]
b. Write a program to input a string and then using pointer find how many vowels
present in the string. [CO4/PO3]
4)
a. Write a program to create an UDF which accepts a number and finds the reverse of it
using call by address concept. [CO4/PO3]
b. Write a program to create an UDF which accepts two strings and then concatenates
both strings (use character pointers as parameters in UDF) [CO4/PO3]
5)
a. Write a program to create user defined function called swap having two integer
pointers as its arguments and it has no return value. Call this function for
interchanging two values using call-by-address. [CO4/PO3]
b. Write a program to input 10 integers into an array. Create an UDF which accepts the
base address of array and finds the sum of even numbers and sum of odd numbers
separately. [CO4/PO3]
6)
a. Write a program to create a user defined function which accepts a string using a
character pointer and returns the length of the string. [CO4/PO3]
b. Write a program to store N float values using DMA and create an UDF which finds
the sum of them. [CO4/PO3]
7)
a. Write a program to create a structure BOOKS having members : Book code, book
name, author, cost. Store 10 books details using structure array. Find the total cost of
all books [CO4/PO3]
Page No. 20

b. Write a program to create a structure called complex to represent a complex number.


Perform addition of two complex numbers using UDF [CO4/PO3]
8)
a. Write a program to create a structure for employee code, name and salary. Store five
employee details using structure array and display only employee names whose salary
is greater than 25000 . [CO4/PO3]
b. Write a program to create structure called ITEM having members: item code, name,
price. Create a structure array of size 10. Store the item details and then using a
structure pointer display all the items whose price>=500 [CO4/PO3]

9)
a. What is a pointer ? How a pointer can be used to navigate between memory locations
of 1D array and 2D array? Explain briefly with a suitable example. [CO4/PO3]
b. What is the advantage of a character pointer over a character array? Explain the terms:
array of pointers, pointe to pointer. [CO4/PO3]
10)
a. Explain the syntax and example on malloc(), calloc(), realloc(). Write a program to
allocate N integer memory and then input the numbers and find the average.
[CO4/PO3]
b. Write a program to create user defined function called swap having two integer pointers
as its arguments and it has no return value. Call this function using call-by-address.
[CO4/PO3]
11)
a. Write a program to input 10 integers into an array. Create an UDF which accepts the
base address of array and finds the sum of even numbers and sum of odd numbers
separately. [CO4/PO3]
b. Write a program to store N values using dynamic memory allocation. Then find largest
and smallest number present in it using UDFs MAX() and MIN(). [CO4/PO3]
12)
a. Write a program to store 11 cricket players’ details into an array of structure. The
structure having member’s player name, team name and batting average. Create an
UDF which displays the name of players whose batting average is >=30. [CO4/PO3]
b. Write a program to create a structure called SUBJECTS having members: rollno,
physics, chemistry, maths, total marks. Create a structure array to store 10 students
marks. Calculate the total marks of each student. [CO4/PO3]

You might also like