Question Bank - 18PCS23
Module -1
Questions 6, 8 & 9 are GATE/Placement questions. Check and write answers with justification/comments
Write generations of computer.
Describe various types of computers.
What is a pseudo-code? Write pseudo-code to find maximum in 3 numbers.
Draw the flowchart & write algorithm & Program to compute simple & compound interest.
What is an identifier? What are rules to construct identifier? Classify following as valid/invalid identifier.
num1, $num1, +add, a_2, for, 1st_paper_marks
Explain type conversion with example
Explain structure of a C program with example
Explain syntax with examples of printf() and scanf() statements.
List arithmetic, logical, relational & assignment operators of C with examples.
Explain constants, associativity, precedence with examples.
Evaluate the following expressions:
100%20<=20-5+100%10-20==5>=1!=20
A+=b*=c-=5 where a=3, b=5 & c=8
int a,b; float x; a=4; b=5; x=b/a ;
int a,b; float x; a=4; b=5; x=(float)b/a;
x = a-b/3 + c*2 - 1 when a = 9, b= 12 & c = 13
10 != 10 || 5 < 4 && 8
Evaluate the z=5%3/8*3+4
What will be value of x in following segments:
i. int a,b; float x; a=4; b=5; x=b/a ;
ii. int a,b; float x; a=4; b=5; x=(float)b/a;
Draw a flowchart & write a C program to convert Fahrenheit temperature to Centigrade.
Write a C program to compare the largest of two umbers using conditional operator.
Write a C program to find area of a triangle by given 3 sides (Program should give alert if sum of 2 sides is not greater than 3rd)
Write output of the following C codes:
void main()
{
int a=5, b=2, res1;
float f1=5.0, f2=2.0, res2;
res1=5/2.0+a/2+a/b;
res2=f1/2*f1-f2;
printf(“res1 = %d res2 = %f”,res1,res2);
}
void main()
{
int i=5,j=6,m,n;
m=++i+j++;
n=--i+j--;
printf(“m=%d n=%d”,m,n);
}
int main()
{
int i= 8, j = 5;
float x = 0.005, y = -0.01;
char c = ‘c’, d = ‘d’;
printf(“%d”, (3*i-2* j)%(2*d-c));
printf(“%d”, 2 * ((i / 5) + (4 * (j - 3)) % (i + j - 2)));
return (0);
}
Write the output of following program:
#define cube(x) x*x*x
int main()
{
printf(“%d”, cube(5+2)):
return (0);
}
#define max2(a,b) a>b?a:b
int main()
{
int x=2.y=3,z;
z=2+max2(x,y);
printf(“z = %d”, z):
return (0);
}
int main()
{
int n=7,p;
p=n++;
printf(“p=%d n=%d\n”,p,n);
p=++n;
printf(“p=%d n=%d\n”,p,n);
printf(“%d%d%d\n”,n++,n++,n++);
printf(“%d%d%d\n”,++p,++p,++p);
return (0);
}
Module 2
1. Differentiate between while & do...while statement. Explain the syntax of do-while statement. Write a C program to find the factorial of a number using while loop, where the number n is entered by the user. (Hint: factorial of n = 1*2*3*….*n).
2. a. Write a C Program to find GCD of two numbers using ternary operator and for loop.
b. Write a C program to plot a Pascal's triangle
3. a. Write a calculator program in C language to do simple commercial calculator operation like addition, subtraction, multiplication and division using switch statement.
b. Write a C program to plot a Pascal's triangle
4. Write a C Program to display prime numbers within a given range.
5. See the properties of following numbers:
13+53+33 = 153
14 + 64 + 34 + 44 = 1634
they are called Armstrong numbers. Write a C program to display Armstrong numbers within given range
Module 3
(String handling is not in syllabus but necessary for placement & GATE)
1. a. Explain string handling functions strcat(), strcpy() & strcmp().
b. Write a C Program to concatenate two strings without using built-in function strcat( ).
2. a. Write with syntax and example to initialize 2 dimensional arrays
b. Write a C Program to transpose a matrix.
3. a. Write a C Program to find greatest number from two dimensional array.
b. Write a C program to implement Selection Sort
3. a. Write a C Program o replace each character constant of a string with next one except letters ‘a’,’A’,’z’ & ‘Z’. Thus string “Programming in C is a fun” should be modified as “Qsphsannjoh jo D jt gvo”
b. Write a C program to sort strings using Bubble Sort.
5. a. Write a C program to search a name in a sorted list of name using binary search
b. Write a C program to check whether a string (with spaces) is palindrome or not without using built-in function.
Module 4
(1. Storage class is important, 2. Pointers will be covered up to 4th Module)
1 a. What is a function/user defined function (with & without argument/parameter)? Write a function to find LCM of two numbers.
b. Write a function to accept an array of intergers and to sort it using selection sort method.
2. Explain storage class extern, auto, static and register variables with scope and their lifetime & with simple examples.
2. a. Write a C Program to find GCD of 2 numbers using recursion
b. Write a C program to find of comb(n,r) = n!/(r!*(n-r)!) . For factorial use recursion.
3. a. Write a C program to check a number whether it is prime using recursion
b. Write a C program to display Fibonacci series using while loop & recursion
3. a. Explain how pointers and arrays are related with example.
b. Differentiate the declarations
i. int *p[4]; and int (*p)[4];
ii. int *f() and int (*f)()
4. Write a C Program to find sum, mean & standard deviation of array elements using pointer
Module 5
(File handling is not in the syllabus but necessary for placement & GATE)
1. a. What are member operators of structure? Explain their use.
b. Explain Array of structure, Array within structure & structure within structure with definition
c. explain difference in structure & union.
2. How structure variables(objects) are passed as an argument to a function? Write a C program to define array of structure
with fields roll, name & marks for 60 students. Pass this array of structure to a function to sort the records based on marks
in descending order.
3. a. Describe any 5 pre-processor directives of C.
b. What is dynamic memory allocation? Explain different dynamic memory allocation/de-allocation functions of C with
syntax and example.
4. Write a C Program to copy the contents of a file to another file and to display the contents.