Ad
Wednesday, August 24, 2022
C-Programming Previous Year Questions
October 2017
Q1. Answer the following : [10×1=10]
(a) Define reserved word.
(b) State true/false : ‘C’ performs bound checking for an array.
(c) What do you mean by exit control loop.
(d) Give the syntax for ternary operator.
(e) Give the difference between bitwise AND and logical AND.
(f) State properties of Algorithm.
(g) -XYZ is a valid ‘C’ identifier : Comment.
(h) Give the difference between malloc() and calloc().
(i) State True/False : A macro name must always be written in capital letter.
(j) Which function is used to calculate √ x in ‘C’ from math.h library ? Give syntax.
2. Answer the following (any four) : [4×5=20]
(i) Explain ‘C’ program development life cycle.
(ii) Write a note on switch statement.
(iii) Explain self-referential structure.
(iv) Explain the following functions with example :
(a) strrev() (b) strcmp() (c) strlen() (d) strupr() (e)strlwr()
(v) Explain the following with example :
(a) Assignment operator
(b) Conditional operator
(c) Comma operator
(d) Type cast operator
(e) Size of operator
3. Answer the following (any four) : [4×5=20]
(i) Write the algorithm and draw a flowchart for sum of digit until one digit.
(eg: 932; 9+3+2=14 ; 1+4 = 5 = output)
(ii) What will be the output of the following code ? Justify.
main()
{
int a=2;
printf("%d%d",a,a++);
}
(iii) What will be the output of the following code ? Justify.
(a) main()
{
int i;
i = 0 x 10 + 010 + 10;
printf("%d",i);
}
(b) main()
{
char ch = 'A';
printf("%d%d",sizeof(ch), size('A'));
}
(iv) Find and justify the output of the following program :
#include <stdio.h>
int main()
{
int ***r, j, **q, *p, i=7;
p= &i;
q=&p;
r=&q;
printf("%d%d%d \n", *p, **q, ***r);
return (0);
}
(v) Find the errors if any, and justify;
main()
{
float a=3.5;
switch(a)
{
case 0.5 : printf ("Have a nice day....");
break;
case 1.5 : printf ("Have a good day.....");
case 2.5 : printf ("Have a wonderful day....");
break
}
}
(v) Answer the following (Any Four) [4×5=20]
(i) Write a ‘C’ program to insert a number of characters of substring at a given position in string.
(eq: s1= abcdef , s2=pqr, position=2, o/p=abcpqrdef)
(ii) Write a ‘C’ program to store the information of player with attributes : name, number of innings and total score. Calculate the average score of each player and display information of all players.
(iii) Write a ‘C’ program to reverse the element of an array.
(iv) Write a ‘C’ program to print the following series :
1 + 1/x³ + 1/x⁵ + 1/x⁷ +….. 1/xⁿ
(v) Write a ‘C’ program to print the following pattern:
1
1 2
1 2 3
1 2 3 4
5. Answer the following (any two) : [2×5=10]
(i) Write a note on preprocessor.
(ii) Explain jump statement with example.
(iii) Explain memory allocation techniques.
October 2018
Q1. Attempt all of the following. [10×1=10]
(a) Is ‘C’ language high level language ? True/False.
(b) What is a pointer?
(c) State the use of rewind() function.
(d) List the functions for <string.h> file.
(e) What is a recursive function ?
(f) What is a global variable and local variable ?
(g) What is the use of comment operator ?
(h) List the different data types.
(i) List the different Backslash character constants.
(j) Which function is used to calculate ‘square root’ of A in ‘C’
from math.h library ? Give syntax.
Q2. Answer the following (any four) : [4×5=20]
(a) Explain ‘switch-case’ statement with suitable example.
(b) Write notes on :
(i) structure
(ii) union.
(c) What is function ? Explain its definition and declaration with
suitable example.
(d) Explain array with its types. Give example.
(e) Explain the following function with example :
(i) isupper() (ii) islower()
(iii) isalpha() (iv) isdigit()
Q3. Answer the following (any four) : [4×5=20]
(a) Write an algorithm and draw a flowchart for ‘swapping of two
numbers’.
(b) Explain the following dynamic memory allocation functions with
example :
(i) malloc() (ii) calloc()
(iii) realloc() (iv) free()
(c) What will be the output of the following code ? Justify.
(i)
#include<stdio.h>
void func(int x, int y, int z)
{
printf(''%d %d %d'', x, y, z);
}
(ii)
void main()
{
int var=15;
func(var, var++, ++var);
}
(d) Write output for the following code :
#include<stdio.h>
int print(int a, int b)
{
printf(''\n a=%d\n'', a);
printf(''\n b=%d\n'', b);
return 0;
}
main()
{
int(*fptr) (int, int);
fptr=print;
print(2, 3);
fptr(2, 3);
return 0;
}
(e) Find and correct error in the following code :
#include(stdio.h)
int main()
{
char ch='c';
const char *ptr=&ch;
*ptr='a';
return 0;
}
Q4. Answer the following (any four) : [4×5=20]
(a) Write a program to display the following pattern (n lines) :
*
* * *
* * * * *
(b) Write a program to reverse all elements of a matrix.
(c) Write a program to copy the contents of one text file to another.
(d) Write a program to check the given number is positive or
negative using function.
(e) Write a menu driven program using string library functions
for :
(i) Copy of string
(ii) Concatenation of two strings.
Q5. Answer the following (any two) : [2×5=10]
(a) Write a note on ‘command line arguments’.
(b) Explain :
(i) Simple macro substitution
(ii) Macros with argument
(iii) Nesting of macros.
(c) Explain the following :
(i) pointer to pointer
(ii) goto statement
(iii) Break statement
April 2019
Q1) Attempt all of the following: [10×1=10]
a) What is machine language?
b) Define operator.
c) Give the use of rewind ( ) function.
d) Give the difference between break and continue statement.
e) What is formal parameter?
f) While passing array to a function, address of first element of array is
passed. State true or false.
g) What is dynamic memory allocation?
h) Which function is used to join two strings? Give syntax.
i) Give the difference between structure and union.
j) Which function is used to move file pointer?
Q2) Attempt any four of the following: [4×5=20]
a) Explain for loop with suitable example.
b) Give syntax and use of following functions:
i) strlen
ii) strcat
iii) strcmp
iv) strcpy
v) strrev
c) Define array. Explain row major and column major order of matrix
representation.
d) Define file. Explain any four file functions.
e) Explain malloc and calloc functions with example.
Q3) Attempt any four of the following: [4×5=20]
a) Write algorithm and draw flowchart to find out factorial of a number.
b) What is the output of following C code? Justify
int main ( )
{
static char name [] = “programming”;
char *s ;
s = & name [6] - 4;
while (*s)
printf (“%c”, * s ++);
}
c) What is the output of following C code? Justify
# define Test (x) (x * x)
int main ( )
{
int a, b = 3;
a = Test (b + 3);
printf (“% d - % d”, a, b);
}
d) What is the output of following C code? Justify.
struct employee
{
char ename [20];
int empno;
} el, * ptr, e[20];
int main ( )
{
printf (“\n%d”, sizeof (el));
printf (“\n%d”, sizeof (ptr));
printf (“\n%d”, sizeof (el));
}
e) What is the output of following C code? Justify.
int main ( )
{ int a =5, b = 10, c = 7;
predict ( a, & b, c);
printf (“% d - % d- % d”, a, b, c);
}
void predict (int p, int *q, int r)
{
p = 50;
*q = *q * 10;
r = 77;
}
Q4) Attempt any four of the following: [4×5=20]
a) Write a C program to accept a number and print its reverse.
b) Write a C program to accept m×n matrix and print sum of all elements of
a matrix.
c) Write a C program to read a file and display alternate characters from a
file.
d) Write a C program to declare book structure (bookno, bookname,
author). Accept details of n books and display books of particular author.
e) Write a C program to print following pattern for n lines.
1
2 3
4 5 6
7 8 9 10
Q5) Attempt any two of the following: [2×5=10]
a) Explain different types of operators available in C.
b) Explain the structure of C program.
c) Give syntax and use of following functions:
i) getchar
ii) putchar
iii) puts
iv) printf
v) scanf
April 2018
Q1. Attempt 1. all of the following : [10×1=10]
(a) What is a compiler ?
(b) Explain ones complement operator with example.
(c) Define flowchart.
(d) Give any two limitations of an array.
(e) Which standard input-output library functions are used for string
input and output respectively ?
(f) What is the scope of a variable ?
(g) What is the newline character ?
(h) State the use of fopen() function.
(i) Define Macro.
(j) What is dynamic memory allocation ?
Q2. Attempt any 2. four of the following : [4×5=20]
(a) What are command line arguments ? Explain.
(b) Explain two methods of passing arguments to function with
example.
(c) What is an identifier ? Give the rules of identifier.
(d) Differentiate between structure and union.
(e) Explain the following functions with proper syntax :
(1) fflush( )
(2) remove( )
(3) rename( )
(4) ftell( )
Q3. Attempt any four of the following : [4×5=20]
(a) Differentiate between if-else and switch statement.
(b) Write an algorithm and draw a flowcahrt to find the maximum
of 3 no’s.
(c) Find the output of the following program and justify :
main( )
{ int x = 100;
printf (“\n x = %d”, 10 + x++);
printf (“\n x = %d”, 10 + ++x);
}
(d) Find and justify the output of the following program :
main( )
{ int x [25];
x[0] = 100;
x[24] = 400;
printf (“\n %d %d”, *x, *(x + 24) + * (x + 0));
}
(e) Find and justify the output of the following program :
main( )
{ int i;
for (i = 0; i < 5; i++)
func1( );
}
func1( )
{ static int count = 0;
count = count +l;
printf (“%d \t”, count);
}
Q4. Attempt any 4. four of the following : [4×5=20]
(a) Write a ‘C’ program to accept a number and check whether
it is an Armstrong number.
(b) Write a ‘C’ program to accept a m×m matrix and display the
sum of diagonal elements of the matrix.
(c) Write a ‘C’ program to accept ‘n’ numbers and print the even
numbers.
(d) Write a ‘C’ program to display the following pattern :
A
B C
D E F
G H I J
(e) Write a ‘C’ program for creating a structure employee with
employee number, employee name and salary. Accept details
of n employees and display the employee details having the
highest salary.
Q5. Attempt any 5. two of the following : [2×5=10]
(a) Explain for loop with example.
(b) Explain any four string handling functions with usage.
(c) Explain any two storage classes with proper example.
April 2017
Q1. Answer all the following : [10×1=10].
(a) Define flowchart.
(b) ‘C’ is middle level language. Comment.
(c) State different data types.
(d) Who developed ‘C’ language ?
(e) Explain nested for loop.
(f) Write any two string functions.
(g) Define macro.
(h) State the use of putc( ) function.
(i) Which function is used to calculate Xn in ‘C’ from math.h
library ? Give syntax.
(j) What is the meaning of & and * operators in pointer ?
Q2. Answer the following (any four) : [4×5=20]
(i) Write short notes on the following with example :
(a) Call by value
(b) Call by reference.
(ii) Explain the following functions with example :
(a) fclose( )
(b) fopen( )
(c) fgets( )
(d) fputs( )
(e) fcloseall( ).
(iii) Explain with example :
(a) Global variable
(b) Local variable.
(iv) Differentiate between ‘while’ loop and ‘do-while’ loop.
(v) Explain with example :
(a) Relational operators
(b) Logical operators
(c) Increment operators.
Q3. Answer the following (any four) : [4×5=20]
(i) Write algorithm and draw flowchart for calculating maximum
of two numbers.
(ii) Differentiate between structure and union.
(iii) What will be the output of the following code ? Justify :
(a) Main( )
{
int a=10, b=20;
{
int c=30;
printf("%d %d %d", a, b, c);
}
printf("%d %d %d", a, b, c);
}
(b) Main( )
{
auto int i=10;
{
auto int i=20;
printf("%d\n", i);
}
printf("%d\n", i);
}
(iv) Predicate the output for the following :
(a) Struct student
{
char name [10];
int rollno;
}
stu[4]=
{
"smaran", 1,
"sankalp", 2,
"spandan", 3,
"sarthak", 4
}
(b) main( )
{
struct student *ptr=stu;
for (i=0, i<4; i++)
{
printf("At address % u : %.s % d", ptr,
ptr name, ptr rollno);
ptr ++;
}
}
(v) Explain the concept of recursion. Write a ‘C’ program to calculate
factorial of a given number using recursion.
Q4. Answer the following (any four) : [4×5=20]
(i) Write a ‘C’ program to copy the contents of one file to another
file.
(ii) Write a ‘C’ program to accept two matrices, add them and
display the output.
(iii) Write a ‘C’ program to accept ‘n’ numbers and calculate sum
of factorial such as :
for n=3; 1 ! + 2 ! + 3 ! = 9.
(iv) Write a ‘C’ program to count no. of digits, no. of spaces, no.
of lower case letters and no. of upper case letters from a
given input string.
(v) Write a ‘C’ program to print the following pattern :
(a)
*
* * *
* * * * *
(b)
1
2 2
3 3 3
4 4 4 4
Q5. Answer the following (any two) : [2×5=10]
(i) Explain actual parameters and formal parameters.
(ii) Explain concept of pointer to pointer with example.
(iii) Explain ‘break’ and ‘continue’ statement with example.
April 2016
Q1. Attempt all of the following : [10×1=10]
(a) State one advantage of assembly language.
(b) Which is ‘C’ language called middle level ?
(c) State the difference between compiler and interpreter.
(d) Write the use of size of operator.
(e) Define array.
(f) What is a pointer ?
(g) ‘A function can return multiple values’. Comment.
(h) What is the use of · operator ?
(i) What is a macro ?
(j) State the use of ftell() function.
2. Attempt any four of the following : [4×5=20]
(a) Explain the basic data types in ‘C’.
(b) Explain the switch-case statement with suitable example.
(c) What is a structure ? Give differences between structure and union.
(d)Explain with example row and column major representation of two-dimensional array.
(e) What is a function ? Explain how it is declared and defined. Give example.
3. Attempt any four of the following : [4×5=20]
(a) Write an algorithm and draw a flow chart to check if a number is prime.
(b) Write a program using recursive function to find factorial of a number.
(c) Find and correct errors in the following program :
#include<stdio.h>;
void main()
{
int a[n];
printf("How many numbers : ");
scanf("%d",&n);
for(i=0;i<=n ; i++)
scanf("%f",&a[i]);
}
(d) What is the output of the following program ?
void main()
{
char str[]="program";
char *ptr = str;
printf("%c%c",*ptr,*ptr+4);
ptr = ptr + 3;
printf("%c%c", *ptr, *(ptr+2));
}
(e) Write the output of the following program and justify :
int change(int x, int *y)
{
x= x + 5;
*y = *y + 5;
}
main()
{
int a=10, b=20;
change(a,&b);
printf("%d%d",a,b);
}
4. Attempt any four of the following : [4×5=20]
(a) Write a program to display the following pattern (n lines) :
1
1 2
1 2 3
1 2 3 4
(b) Write a program to find the sum of all elements of a matrix.
(c) Write a program to accept student information using structure (roll number, name, percentage) for n students. Display students details having highest percentage.
(d) Write a program to copy the contents of one text file to another.
(e) Write a menu driven program using string library functions for:
(i) Length of string
(ii) Comparing two strings
5. Attempt any two of the following : [2×5=10]
(a) What are command line arguments ? How are they declarred ? Give the advantages of command line arguments.
(b) Explain the following :
(i) Break and continue
(ii) Static storage class.
(c) Explain bitwise operators in ‘C’ with examples.
April 2015
Q1. Answer the following :
(a) Explain conditional operator.
(b) Write any two advantages of ‘C’..
(c) Evaluate the following ‘C’ expression
ans = 25/4 + 3 – 7% 3 + 2
What will be the value of ans ?
(d) The default case in ‘switch’ statement must be at the end.
Comment.
(e) Define scope of a variable.
(f) Write syntax for declaring Void Pointer.
(g) What is use of atoi( ) function ?
(h) What is size of the following union ?
union xyz
{ int x[20];
char s[20];
}
(i) Define Preprocessor.
(j) What is use of gets( ) function ?
Q2. Answer the following (any four) : [4×5=20]
(a) Differentiate between While and Do-while loops.
(b) Explain various operations possible on pointers.
(c) Explain row major and column major representation for arrays
with example.
(d) Differentiate between compiler and interpreter.
(e) Explain increment and decrement operators with example.
Q3. Answer the following (any four) : [4×5=20]
(a) Write Algorithm and draw flowchart to find largest of ‘n’
numbers.
(b) Find and justify the output of the following :
main()
{
int p[6]= {1,2,3,4,5,6};
int *ptr = p;
printf("%d", *(p + 4));
printf("%d", p[2]);
printf("%d", *ptr);
}
(c) Find and justify the output of the following :
main()
{
int m[5] = {10,20};
int i, ans = 0;
for (i=0; i<5; i++)
{
ans = ans + m[i];
printf("%d\n",ans);
}
}
(d) Find and justify the output of the following :
main()
{
int x = 50;
int y = 100;
{
int x = 20;
int z = x + y;
printf("%d\n",z);
}
printf("%d\n%d",x,y);
}
(e) Find and justify output of the following :
main()
{
int incr(int);
int x=1; ans=0, i;
for(i=0;i<3;i++)
{
ans= ans + incr(x);
}
prinf("%d",ans);
}
int incr(int x)
{
return(x + 1);
}
Q4. Answer the following (any four) : [4×5=20]
(a) Write a ‘C’ program to check whether a given number is palindrome
or not.
[Palindrome is a number whose reverse and the original number
is same].
(b) Write a ‘C’ program to accept ‘n’ elements into a 2–D Array
using Dynamic Memory Allocation. Find the sum of element
of the array.
(c) Write ‘C’ program to copy one string to another without using
standard library function such that the cases of the characters
are inverted.
[e.g. Delhi o/p dE|hI]
(d) Write ‘C’ program to create a new file and accept data from
user and save it in file. Display the count of total number
of characters from file.
(e) Write a ‘C’ program to find x raise to y using recursive
function.
Q5. Answer the following (any two) : [2×5=10]
(a) Write a note of basic structure of ‘C’ program.
(b) Differentiate between auto and static storage classes.
(c) Explain Macro preprocessor directives with suitable example.
SY- 2015
Q1. Answer all the following : [10×1=10]
(a) Define Algorithm.
(b) What is source code ?
(c) Who developed C language ?
(d) What is a token ?
(e) Explain conditional operator ?
(f) What is the use of getchar() and putchar() function in ‘C’ ?
(g) What are the types of scope of a variable ?
(h) State the use of ftell() function.
(i) Define Preprocessor.
(j) What is a string ?
Q2. Answer the following (any four) : [4×5=20]
(i) Write a short note on “User defined data types in C’.
(ii) Explain Register storage class.
(iii) Explain structures in ‘C’ ?
(iv) Differentiate between ‘while’ loop and ‘do while’ loop ?
(v) Explain the following functions with example :
(a) fprintf()
(b) fscanf()
(c) fread()
(d) fwrite()
Q3. Answer the following (any four) : [4×5=20]
(i) Differentiate between algorithm and flowchart.
(ii) What will be the output of the following code ? Justify.
#include <stdio.h>
void main()
{ int i = 3;
switch(i)
{ case 0 : printf (" I am here");
break;
case 1 + 0 : printf ("I am in second case");
break
case 4/2 : printf ("I am in the third case");
break
case 8% 5 : printf ("good bye");
break
}
}
(iii) What is the O/P of the following ‘C’ code? Justify.
#include <stdio.h)
void main()
{ char*S = "hello";
char*P = S;
printf ("%c\t%c",*(p + 3), s[1]);
}
(iv) What is the output of this C code ? Justify.
#include <stdio.h>
int main()
{ int a = 1, b = 1, c;
c = a++ + b;
printf ("%d, %d", a, b);
}
(v) Write a function to calculate the length of a string. (Don’t use
std. library functions).
Q4. Answer the following (any four) : [4×5=20]
(i) Write a ‘C’ program to accept n numbers and sort them in
descending order.
(ii) Write a ‘C’ program to copy the contents of one file to
another file. The file names are passed using command line
arguments.
(iii) Write a ‘C’ program to reverse the digits of a number.
(iv) Write a ‘C’ program to accept m × n matrix and generate
a (m + 1) × (n + 1) matrix such that the m + 1th row contains
sum of elements of corresponding columns and n + 1th column
contains sum of elements of corresponding rows.
(v) Write a ‘C’ program to accept n names and display them and
search for a particular name.
Q5. Answer the following (any two) : [2×5=10]
(i) Differentiate between a function and macro.
(ii) Explain ‘break’ and ‘continue’ statement with an example.
(iii) Explain recursion with an example.
About Abhishek Dhamdhere
Qna Library Is a Free Online Library of questions and answers where we want to provide all the solutions to problems that students are facing in their studies. Right now we are serving students from maharashtra state board by providing notes or exercise solutions for various academic subjects
No comments:
Post a Comment