Sample Paper
Sample Paper
me/placement_0
ls
ia
er
at
M
e
im
Pr
Also, don't share this PDF with anyone as if they will score good marks too your
percentile will get decreased
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Some Questions don’t have options since we couldn’t find the options while trying to get
questions from students who have already given TCS Test but anyways we have put the
questions so can atleast give them a shot.
3. None of these
ls
4. Passed to a function as argument.
ia
er
Correct Op: 4
at
M
Q. Which of the following uses structure?
e
1. Linked Lists
im
2. Array of structures
Pr
3. All of these
T
4. Binary Tree
Q
Correct Op: 3
N
Q. Strings are character arrays. The last index of it contains the null-terminated
character
1. \t
2. \1
3. \0
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
4. \n
Correct Op: 3
1. String
2. Structure
3. Array
ls
4. Files
ia
Correct Op: 2
er
at
M
Q. What function should be used to free the memory allocated by calloc() ?
e
1. free();
im
2. malloc(variable_name, 0)
Pr
3. dealloc();
T
4. memalloc(variable_name, 0)
Q
Correct Op: 1
N
1. conio.h
2. stdio.h
3. math.h
4. Dos.h
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Correct Op: 3
1. Pointer to integer
2. None of these
3. Pointer to pointer
4. Invalid declaration
ls
Correct Op: 3
ia
er
at
Q8. Which of the following special symbol allowed in a variable name?
M
1. (underscore)
e
2. - (hyphen)
im
3. | (pipeline)
Pr
4. * (asterisk)
T
Correct Op: 1
Q
N
1. Uppercase letters
2. None of these
3. Lowercase letters
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Correct Op: 3
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
ls
++param;
ia
}
er
int main(){
at
M
char* string = (char*)malloc(64);
e
strcpy(string, "hello_World");
im
myfunc(&string);
Pr
myfunc(&string);
T
printf("%s\n", string);
Q
return 0;
1. hello_World
2. ello_World
3. lo_World
4. llo_World
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Correct Op: 1
#include <stdio.h>
void main()
ls
int k = 5;
ia
int *p = &k;
er
int **m = &p;
at
M
printf("%d%d%d\n", k, *p, **p);
e
}
im
a) 5 5 5
Pr
b) 5 5 junk
T
c) 5 junk junk
Q
Correct op: D
Explanations
Q. Which of the following statements about stdout and stderr are true?
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Correct Op: D
Explanation -
ls
a) False. b) Not by default. c) Not by default. d) True.
ia
er
Q: Given the below statements about C programming language:
at
1) main() function should always be the first function present in a C program file
M
2) all the elements of an union share their memory location
e
im
3) A void pointer can hold address of any type and can be typcasted to any type
Pr
A) 2,3
B) 1,2
C) 1,2,3
D) 1,2,3,4
Correct Op - A
Explanations
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
A void pointer can hold address of any type and can be typcasted to any type -
True
In C, if an object that has static storage duration is not initialized explicitly, then:
ls
— if it is an aggregate, every member is initialized (recursively) according to these
ia
rules;
er
— if it is a union, the first named member is initialized (recursively) according to
these rules.
at
M
e
im
B) all the variable declared inside the function automatically will be assigned
Q
C) It should be called only within the same source code / program file.
Correct Op: C
Access to static functions is restricted to the file where they are declared.
Therefore, when we want to restrict access to functions, we make them static.
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
while (0 == 0) { }
C) It compares 0 with 0 and since they are equal it will exit the loop immediately
D) It has syntax error as the same number is being compared with itself
Correct Op: B
while( 0==0) {} is equivalent to while(1) {}
ls
ia
1. What will happen if in a C program you assign a value to an array element
er
whose subscript exceeds the size of array?
Answer: Option C
T
Explanation:
Q
If the index of the array size is exceeded, the program will crash. Hence "option c"
N
is the correct answer. But the modern compilers will take care of this kind of
errors.
int (*ptr)[10];
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Answer: Option B
ls
B.First element of the array
ia
C.Base address of the array
er
D.Address of the last element of array
Answer: Option C
at
M
Explanation:
e
im
The statement 'C' is correct. When we pass an array as a function argument, the
base address of the array will be passed.
Pr
T
#include<stdio.h>
N
int main()
int i, j, m;
i = ++a[1];
j = a[1]++;
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
m = a[i++];
return 0;
A.2, 1, 15
B.1, 2, 5
C.3, 2, 15
ls
D.2, 3, 20
ia
Answer: Option C
er
Explanation:
at
M
Step 1: int a[5] = {5, 1, 15, 20, 25}; The variable arr is declared as an integer array
with a size of 5 and it is initiapzed to
e
im
Step 6: printf("%d, %d, %d", i, j, m); It prints the value of the variables i, j, m
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
A.Yes
B.No
Answer: Option B
Explanation:
No, both the statements are same. It is the prototype for the function fun() that
accepts one integer array as an parameter and returns an integer value.
ls
ia
6. Are the expressions arr and &arr same for an array of 10 integers?
er
A.Yes
B.No
at
M
Answer: Option B
e
im
Explanation:
Pr
Both mean two different things. arr gives the address of the first int, whereas the
&arr gives the address of array of ints.
T
Q
Answer: Option C
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Explanation:
This function is the same as the modulus operator. But fmod() performs floating
point divisions.
ls
B.External, Internal and None
ia
C.External and None
er
D.Internal
Answer: Option B
at
M
Explanation:
e
im
Internal pnkage-> means static variables and functions with file scope.
A. * (asterisk)
B. | (pipepne)
C.-(hyphen)
D._(underscore)
Answer: Option D
Explanation:
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Variable names in C are made up of letters (upper and lower case) and digits. The
underscore character ("_") is also permitted. Names must not begin with a digit.
=> foo
=> Bar
=> BAZ
=> foo_bar
ls
=> _foo42
ia
=> _
er
=> QuUx
at
M
10. Is there any difference between following declarations?
e
im
2 : int fun();
D. None of these
Answer: Option B
Explanation:
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
ls
(A) 2
ia
(B) -2
er
(C) 1
(D) Error
at
M
--2 is incorrect, // Invalid because lvalue is required to increment
e
im
main()
T
{
Q
int i=-1;
N
printf(“%d,%d”,i,-i);
(A) -1, 1
(B) -1, -1
(C) 1, 1
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
(D) 0, 1
main()
ls
{
ia
int var=30; //Inner block
er
printf(“%d”,var);
at
M
}
e
}
im
Pr
main()
{
int var=20; // scope of the local variable is within function or
block
printf(“%d,”,var); //outer block
{
int var=30; //Inner block
printf(“%d,”,var);
}
printf(“%d”,var); //again in outer block
}
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Note: among logical operators logical NOT has right to left associativity , i.e . !
operator
ls
main()
{
ia
int x,a=10;
er
x=9*5+7/3-6+a; //45+2-6+10 = 51 // 7/3 =2 int division
printf(“%d”,x);
} at
M
(A). 51 (B). 51.5 (C). 31
(D). None of these
e
im
main()
{
int a=10,x;
T
x= a-- + ++a;
Q
printf(“%d”,x);
}
N
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
ls
{
int i=10,j=2,k=0,m;
ia
m=++i&&++j&&++k; // m = 11 && 3 && 1 = 1
er
printf(“%d%d%d%d”,i,j,k,m);
}
a. 11,3,1,1 b. 11,2,0,1
at
M
c. 11,3,1,0 d. 10,2,0,1
e
im
main()
{
int i=10;
T
printf(“%d,%d”,++i,++i);
Q
}
a. 11,12 b. 12,11
N
c. 10,11 d. 11,10
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
a. Error b. 5,1
c. 2,1 d. 5,5
ls
a. Error b. 5,1
c. 2,1 d. 5,5
ia
er
Predict the output of following code:
main()
{
at
M
int x=10,y=-10;
printf(“%x \t”,x<<2); // %X hexadeciamal value displayed
e
printf(“%x\t”,y>>2);
im
}
a. 28 fffd b. 40 -3
Pr
c. Error d. 0,1
In bitwise operations if number is +ve then simply specied number of bits shifted
Q
in specified direction L or R.
If Number is –VE then 2’s complement is used
N
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
}
a. a is the smallest number b. b is the smallest number
c. Error d. Both statements
ls
printf(“hai”);
else
ia
printf(“hello”);
er
}
a.
c.
Error
hello
b. hai
d. No output
at
M
e
main()
{
Pr
printf(“False”);
Q
}
N
a. True b. False
c. True False d. Error
a. True b. False
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
ls
a. Error b. HaiFace
c. HaiFocus d. Face
ia
er
Predict the output of following code:
{
main() at
M
if( printf(“”)) // prints content of printf statement and
//takes length of the string for if case //execution in this
e
printf(“Face”);
else
printf(“Focus”);
Pr
}
T
a. Error b. Face
Q
c. “”Focus d. Face
N
a. Error b. OTwoFace
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
c. HaiFocus d. Face
ls
Predict the output of following code:
ia
main()
er
{
int a=100,b=300;
if(a>50) at
// No braces, so only one immediate statement is part of if
a=200;
M
b=400;
printf(“%d”,b);
e
}
im
a. 400 b. 300
Pr
c. 100 d. Error
T
Q
{
int i = 1;
while( i < = 5)
{
printf(“%d “, i);
if ( i < 2)
goto here;
}
}
fun()
{
here:
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
printf(“\n I am here”);
}
ls
a. Tom b. Jerry
ia
c. Tom Jerry d. Error
er
Predict the output of following code: at
M
main()
{
e
int a=2;
im
switch(a)
{
case 1: printf(“one”);
Pr
default:printf(“Invalid option”);
Q
}
}
N
a. onetwothree
b. Invalid option
c. one two
d. None of these
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
a. 2 or 4 b. 1 or 3
c. Garbage value d. ASCII value of a
NOTE:
// sizeof takes ascii value of character and determines number of bytes required
by it. Ascii is number, Number is of type int. so integer requires either 2 in 16
or 4 in 32 bit machine
ls
{
int a=b=c=d=10; // error: ‘b’ , ‘c’, ‘d’ undeclared
ia
printf(“%d,%d,%d,%d”,a,b,c,d);
er
}
a. Error
c. GV,GV,GV,10
at
b. 10,10,10,10
d. GV,GV,GV,GV
M
NOTE: GV-Garbage Value
e
im
main()
{
int b,c,d;
T
int a=b=c=d=10;
Q
printf(“%d,%d,%d,%d”,a,b,c,d);
}
N
a. Error b. 10,10,10,10
c. GV,GV,GV,10 d. GV,GV,GV,GV
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
a. Error b. 195
c. 201 d. “ab”
ls
if(a==b) // datatype is different cant be compared; hence result will be 0
printf(“equal”);
ia
else
er
printf(“not equal”);
}
main()
{
printf(“%%%%”);
Pr
}
T
Note:
N
A `%' is written.
No argument is converted.
The complete conversion specification is`%%'.
main()
{
printf(“%d”);
}
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Note:
after 1st statement execution:
ks
ls
After 2nd : k mi
After 3rd : ha i
ia
er
Predict the output of following code:
{
main() at
M
100; // valid but no effect
printf(“%d”,100);
e
}
im
a. Error b. 100
Pr
main()
{
N
printf(“%d”,printf(“FACE”)); //valid
}
Note:
First prints content of printf statement
Then prints its length in outer printf statement
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Note: Output
FACE4
First Second Third
First Second Third 0.000000 0.000000 0.000000
First Second Third 676
ls
printf(“FACE”+2); // valid skip specified number of
//characters from start
ia
}
er
a. FACE b. FA c. CE d. Garbage value
int a=2000;
im
a. 2000 b. 20
c. 4000 d. Garbage value
T
Q
{
int x,a=10;
x=a==10?printf("hai\t"):printf("hello\n");
printf("%d",x);
}
Note:
First prints content of printf for the case true
Then printf its length stored in x
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
a. 0 b. 1 c. 5 d. Error
ls
first.name last name nUMBER
midname. 4321
ia
er
a. 5 b. 3 c. 2 d. More than 5
enum{i=10,j=20,k=50};
im
}
Q
Output: Errors
N
#define a 10
int main()
{
#define a 50 //Warning is raised for redefining a
printf("%d",a); //Prints new value of a i.e. 50
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Output: 50
ls
}
ia
Output: 9
er
Predict the output
#include <stdio.h>
int main(void)
at
M
{
http://prepinsta.com/ //valid specification http://
e
return 0;
}
Pr
#include <stdio.h>
int main(void)
{
int x = printf("PrepInsta"); //first prints message then assigns length its to x
printf("%d", x);
return 0;
}
(A) PrepInsta9
(B) PrepInsta10
(C)PrepInstaPrep
(D) PrepInsta1
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
ls
Output of following program?
#include<stdio.h>
ia
int main()
er
{
printf("%d", printf("%d", printf(“%d”,543210)));
}
return 0; at
M
(A) 54321061 (B) 543210 (C) 5432101 (D) 5432106
e
im
int main()
{
float c = 5.0;
printf ("Temperature in Fahrenheit is %.2f", (9/5)*c + 32);
return 0;
}
(A) Temperature in Fahrenheit is 41.00
(B) Temperature in Fahrenheit is 37.00
(C) Temperature in Fahrenheit is 0.00
(D) Compiler Error
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
#include<stdio.h>
int main(){
int a=2,b=7,c=10;
c=a==b; //assign 0 to c
printf("%d",c);
return 0;
}
Output: 0
ls
What will be output of the following program?
ia
er
#include<stdio.h>
void main(){
int x;
x=10,20,30;
at
// Assigns first value to z i.e. 10
M
printf("%d",x);
return 0;
e
}
im
Output: 10
Pr
T
#include<stdio.h>
int main(){
N
int a=0,b=10;
if(a=0){ //value a is 0 hence else case is executed
printf("true");
}
else{
printf("false");
}
return 0;
}
Output: false
int main()
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
{
signed char i=0;
for(; i >= 0; i++)
printf("%d\n", i);
getchar();
return 0;
}
ls
for (k = 0.0; k < 3.0; k++)
printf("Hello");
ia
}
er
a) Run time error
b) Hello is printed thrice
c) Hello is printed twice
at
M
d) Hello is printed infinitely
e
# include <stdio.h>
int main()
Pr
{
int i=0;
for(i=0; i<20; i++)
T
{
Q
switch(i)
{
N
case 0: i+=5;
case 1: i+=2;
case 5: i+=5;
default: i+=4;
break;
}
printf("%d ", i);
}
getchar();
return 0;
}
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
// i++ in for loop changes i=17 then default case 17+4=21 ends loop
main()
{
int a[20]={1,2,3};
printf(“%d”,sizeof(a));
}
a. 20 b. 6 c. Error d. 40 or 80
ls
20*2 = 40 bytes or 20 * 4 = 80 in case 32 bit m/c
ia
Predict the output of following code:
er
main()
{
int a[]={1,5}; at
printf("%d,",*a); //a is base address i.e. a[0] *a its content
M
(*a)++; //content of a[0] is incremented by 1
printf("%d",*a); //new value will be 2
e
}
im
a. 1, 5 b. 1, 2 c. Error d. 1, 6
Pr
{
Q
int a[3]={1,2,3};
printf(“%d”, 2[a]); // 2[a] → a[2] → *(a+2) all are same
N
a. 3 b. 2 c. Error d. 6
a. 2 b. h c. Error d. I
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
h→0
a→1
i→2
a. 1 b. Garbage c. Error d. 2
ls
Predict the output of following code:
ia
main()
er
{
int i=0,n;
int a[10]={1,2,3,4,5,6,7,8};
n=a[++i]+ i++ + a[i++] + a[i];
at
M
printf(“%d”,n);
}
e
im
a. 7 b. 10 c. 9 d. 8
Pr
main()
{
N
int a[][]={{1,2},{3,4},{5,6}};
printf(“%d”,a[1][1]);
}
Output: 4
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
a. Error b. 1 c. 0 d. 6
ls
Note: base address of the array is compared
ia
er
Predict the output :
{
main() at
M
int a=10,*p;
int *vp;
e
p=&a;
im
vp=p;
printf(“%d”,*p); // p→ a both p & vp points to a
printf(“%d”,*vp); // vp → a
Pr
}
T
a. 1, 2 b. 2, 2 c. 1, 1 d. Error
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
main()
{
int a=10,*p;
p=&a;
printf("%d",*&*p);
}
ls
}
ia
a. -99 b. c c. Error d. b
er
Predict the output of following code:
main()
at
M
{
int i=10,j=20;
e
int *p,*q;
im
}
T
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
a. 49 b. 56 c. 64 d. Garbage value
ls
ia
er
Find the error/output.
at
M
#include<stdio.h>
int i; // i =0; initialized by default value
e
int kunfu();
im
int main()
{
Pr
while(i)
{
kunfu();
T
main();
Q
}
printf("Lovely\n"); //only executes
N
return 0;
}
int kunfu()
{
printf("Pretty");
}
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
int calc(int);
int main()
{
int a, b;
a = calc(123);
b = calc(123);
printf("%d, %d\n", a, b);
return 0;
}
int calc(int n)
{
int s, d;
if(n!=0)
ls
{
d = n%10;
ia
n = n/10;
er
s = d+calc(n);
}
else
return 0;
at
M
return s;
}
e
im
a. 6 6 b. 4 4 c. 2 8 d. Compilation error
Pr
T
Q
f(int p, int q)
{
int p;
p = 5;
return p;
}
a. 5
b. 0
c. Missing parenthesis in return statement
d. Error: re-declaration of p
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
ls
float sub(float a, float b) //function not declared
ia
{
er
return (a - b);
}
a. 2 b. Compilation error
at
M
c. 1.300000 d. Garbage value
e
im
Pr
T
struct student
{
N
int stuid=1234;
char stuname[5]= “abcde”; //invalid can’t initialize members
}s1;
main()
{
struct student s1;
printf( “%d,%s”,s1.stuid,s1.stuname);
}
a. 1234,abcde
b. 12341234
c. Error
d. abcdeabcde
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
ls
{
struct employee ;
ia
printf( “%d,%f”,emp1.empid,emp1.empbasic);
er
}
a.
b.
13, 13
13,0.000000
at
M
c. Error
d. 13, garbage value
e
im
Pr
T
main()
{
N
struct mystruct
{
int a;
mystruct b; // structure must define before use
mystruct *p;
};
}
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
}s1={1234,“abcde”};
main()
{
struct student s2={5678, “abcde”};
if(s1==s2) //invalid comparision struct instances
ls
printf(“true”);
else
ia
printf(“false”);
er
}
struct birthdate
im
{
int date;
Pr
int month;
int year;
};
T
Q
main()
{
N
struct student
{
int stuid;
char stuname[20];
struct birthdate dob;
} s1={1234, “abcde”};
printf(“%d”,sizeof(s1)); // sizeof(int)+sizeof(stuname)+sizeof(birthdate)
}
a. 13 b. 28 c. Error d. 7
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
ls
a. 10, 10 b. 2020 c. Error d. 1020
ia
er
Predict the output of following code:
at
M
struct birthdate
{
e
int date;
im
int month;
int year;
Pr
};
main()
{
T
union student
Q
{
int stuid;
N
char stuname[2];
struct birthdate dob; //dob require larger memory hence max size of ul is 6
} u1={1234, “ab”};
printf(“%d”,sizeof(u1));
}
a. 10 b. 28 c. Error d. 6
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
int y;
};
ls
ia
er
Choose the correct option to print out a & b: at
M
#include<stdio.h>
float a;
e
double b;
im
a. printf("%f %lf", a, b)
Pr
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
ls
{
ia
\\missing statement }
er
long int fact(int n) {
if(n>=1)
at
M
return n*fact(n-1);
e
im
else
return 1;
Pr
}
T
Q
N
Options
A. printf(“%ll\n",fact(5));
B. printf("%u\n",fact(5));
C. printf("%d\n",fact(5));
D. printf("%ld\n",fact(5));
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
If a function’s return type is not explicitly defined then it’s default to (In C).
A. int
B. float
ls
ia
C. void
er
D. Error
at
M
For passing command line argument the main function should be like
A. int main(char *argv[], int argc)
e
im
Options
A. 5
B. 1
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
C. 0
D. 3
D. enum
ls
ia
er
Which has the highest precision?
A. float
B. double
at
M
C. unsigned long int
e
D. Long int
im
The following table provide the details of standard floating-point types with storage sizes
and value ranges and their precision −
T
Q
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
{
while(x!=y) {
ls
if(x>y)
ia
return fg(x-y,y);
er
else
return fg(x,y-x);
} at
M
return x; }
e
Options
im
A. 3
B. 6
Pr
C. 9
D. Error
T
Q
Free()
Truncate()
delete()
release()
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
ls
Till Page 46 F
ia
er
at
M
Question 1: Use of an increment statement or decrement statement in C?
e
Answer:
im
There are actually two ways you can do this. One is to use the increment operator
Pr
value of x by 1.
Q
N
2. post increment: (print then incremented value will be in buffer). Same thing will
be with decrement.
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Answer:
Answer:
ls
ia
er
Question 4: What is the difference between the = symbol and == symbol?
Answer: at
M
The = symbol is often used in mathematical operations. It is used to assign a
e
value to a given variable. On the other hand, the == symbol, also known as equal
im
Answer:
N
<> is incorrect, all other operators are relational operators. While this operator is
correctly interpreted as not equal to in writing conditional statements, it is not the
proper operator to be used in C programming. Instead, the operator != must be
used to indicate not equal to condition.
Question 6: Can the curly brackets { } be used to enclose a single line of code?
Answer:
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
While curly brackets are mainly used to group several lines of codes, it will still
work without error if you used it for a single line. Some programmers prefer this
method as a way of organizing codes to make it look clearer, especially in
conditional statements.
Question 7: Can I use int data type to store the value 32768? Why/why not?
Answer:
No. int data type is capable of storing values from -32768 to 32767. To store
ls
32768, you can use long int instead. You can also use ‘unsigned int, assuming
you don’t intend to store negative values.
ia
er
at
Question 8: Can two or more operators such as \n and \t be combined in a single
M
line of program code?
Answer: Yes, it’s perfectly valid to combine operators, especially if the need
e
im
arises.
For example: you can have a code like ‘printf (‘Hello\n\n\’World\’)’ to output the
Pr
text ‘Hello’ on the first line and ‘World’ enclosed in single quotes to appear on the
next two lines.
T
Q
N
Answer:
When declaring functions, you will decide whether that function would be
returning a value or not. If that function will not return a value, such as when the
purpose of a function is to display some outputs on the screen, then void is to be
placed at the leftmost part of the function header. When a return value is expected
after the function execution, the data type of the return value is placed instead of
void.
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Question 10: Write a loop statement that will show the following output:
12
123
1234
12345
ls
Answer:
ia
er
for (a=1; a<=5; i++) {
at
M
for (b=1; b<=a; b++)
e
printf("%d",b);
im
printf("\n");
Pr
}
T
Question 1: How would you round off a value from 1.66 to 2.0?
Q
N
A. ceil (1.66)
B. floor (1.66)
C. roundup (1.66)
D. Round to (1.66)
Answer: A
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
#include<stdio.h>
#include<math.h>
int main()
ls
printf("\n Result : %f" , ceil(1.66) );
ia
printf("\n Result : %f" , floor(1.44) );
er
printf("\n Result : %f" , floor(1.66) );
at
M
return 0;
e
}
im
// Output:
Pr
// Result : 2.000000
T
// Result : 2.000000
Q
// Result : 1.000000
N
// Result : 1.000000
#include<stdio.h>
int X=40;
int main()
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
int X=20;
printf("%d\n", X);
return 0;
A.20
B.40
ls
C.Error
ia
D.No Output
er
Answer: A
at
M
Whenever there is conflict between a local variable and global variable, the local
variable gets priority.
e
im
Pr
A. True
Q
B. False
N
Answer: A
Double = 8 bytes.
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
A.True
B. False
Answer: A
True,
float = 4 bytes.
ls
Double = 8 bytes.
ia
er
at
Question 5: If the definition of the external variable occurs in the source file
before its use in a particular function, then there is no need for an extern
M
declaration in the function.
e
A. True
im
B. False
Pr
Answer: A
T
True, when a function is declared inside the source file, that function (local
Q
function) get a priority than the extern function. So there is no need to declare a
N
Question 6: If the definition of the external variable occurs in the source file
before its use in a particular function, then there is no need for an extern
declaration in the function.
A. True
B. False
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Answer: A
True, When a function is declared inside the source file, that function(local
function) get a priority than the extern function. So there is no need to declare a
function as extern inside the same source file
Question 7: Size of short integer and long integer can be verified using the size
of() operator.
A. True
B. False
ls
Answer: A
ia
True, we can find the size of short integer and long integer using the sizeof()
er
operator.
at
M
Question 8: Range of double is -1.7e-38 to 1.7e+38 (in 16 bit platform - Turbo C
e
under DOS)
im
A. True
Pr
B. False
T
Answer: B
Q
Question 9: Size of short integer and long integer would vary from one platform to
another.
A. True
B. False
Answer: A
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
A. True
B. False
Answer: Option B
ls
False, the range of float is -3.4e-38 to 3.4e+38.
ia
er
Question 1: What is wrong in this statement?
scanf(%d,whatnumber);
at
M
Answer:
e
im
An ampersand '&' symbol must be placed before the variable name whatnumber.
Placing & means whatever integer value is entered by the user is stored at the
Pr
address of the variable name. This is a common mistake for programmers, often
leading to logical errors.
T
Q
N
Question 2: What does the format %10.2 mean when included in a printf
statement?
Answer:
This format is used for two things: to set the number of spaces allotted for the
output number and to set the number of decimal places. The number before the
decimal point is for the allotted space, in this case it would allot 10 spaces for the
output number. If the number of space occupied by the output number is less
than 10, addition space characters will be inserted before the actual output
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
number. The number after the decimal point sets the number of decimal places, in
this case, it’s 2 decimal spaces.
Answer:
ls
ia
Question 4: What are binary trees?
er
Answer:
at
Binary trees are actually an extension of the concept of linked lists. A binary tree
M
has two pointers, a left one and a right one. Each side can further branch to form
additional nodes, which each node having two pointers as well.
e
im
Pr
Answer:
Q
N
4. C uses the top-down approach while JAVA uses the bottom-up approach.
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Answer: Functions are declared within header file. That is function prototypes
exist in a header file, not function bodies. They are defined in library (lib).
Answer:
There are four types of storage classes in C. They are extern, register, auto and
static.
ls
ia
Question 8: What does static variable mean?
er
Answer:
at
Static is an access qualifier. If a variable is declared as static inside a function,
M
the scope is limited to the function, but it will exists for the life time of the
program. Values will be persisted between successive calls to a function.
e
im
Pr
Answer:
T
Q
Question 10: What are macros? What are its advantages and disadvantages?
Answer:
The disadvantage with macros is that they just replace the code they are not
function calls. Similarly the advantage is they can reduce time for replacing the
same values.
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Answer:
Pass by value just passes the value from caller to calling function so the called
function cannot modify the values in caller function. But Pass by reference will
pass the address to the caller function instead of value if called function requires
to modify any value it can directly modify.
ls
Question 2: What is an object?
ia
Answer:
er
at
Object is a software bundle of variables and related methods. Objects have state
and behaviour.
M
e
im
Answer:
kind of problem. After creation the user need not know the specifics of the
Q
working of a class.
N
Answer:
Structure: Initially (in C) a structure was used to bundle different type of data
types together to perform a particular functionality. But C++ extended the
structure to contain functions also.
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
The major difference is that all declarations inside a structure are by default
public.
Class: Class is a successor of Structure. By default all the members inside the
class are private.
Answer:
ls
can vary. The way the compiler and linker handles this is that it assigns
ia
a specific block of memory within the computer to hold the value of that variable.
er
at
M
Question 6: What is the difference between null and void pointer?
e
Answer:
im
A Null pointer has the value 0. Void pointer is a generic pointer introduced by
Pr
ANSI. Generic pointer can hold the address of any data type.
T
Q
Answer:
return nX + nY;
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Answer:
ls
advantageous for the programmer. Under these circumstances, the function or
ia
external class can be declared as a friend of the class using the friend keyword
er
at
Question 9: What do you mean by inline function?
M
Answer: The idea behind inline functions is to insert the code of a called function
e
at the point where the function is called. If done carefully, this can improve the
im
Answer:
An abstract class is a class which does not fully represent an object. Instead, it
represents a broad range of different classes of objects. However, this
representation extends only to the features that those classes of objects have in
common. Thus, an abstract class provides only a partial description of its objects.
Answer:
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
For Array memory allocated is static and continuous. For List memory allocated is
dynamic and random.
Array: User need not have to keep in track of next memory allocation.
List: User has to keep in Track of next location where memory is allocated.
Array uses direct access of stored members; list uses sequential access for
members.
ls
ia
Question 2: What are the differences between structures and arrays?
er
Answer:
at
M
Arrays are a group of similar data types but Structures can be group of different
data types.
e
im
Pr
Answer:
T
Q
A data structure is a way of organizing data that considers not only the items
stored, but also their relationship to each other. Advance knowledge about the
N
relationship between data items allows designing of efficient algorithms for the
manipulation of data.
Question 4: Can you list out the areas in which data structures are applied
extensively?
Answer:
Compiler Design,
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Operating System,
Numerical Analysis,
Graphics,
ls
Answer:
ia
It permits code reusability. Reusability saves time in program development. It
er
encourages the reuse of proven and debugged high-quality software, thus
at
reducing problem after a system becomes functional.
M
e
Answer:
Pr
Answer:
Argument counter
Argument vector
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
Environment vector
Answer:
ls
Answer:
ia
Create two pointers, each set to the start of the list. Update each as follows:
er
while (pointer1) {
at
M
pointer1 = pointer1->next;
e
if (pointer1 == pointer2) {
Pr
print ("circular\n");
T
}
Q
}
N
Question 10: Write a program to swap two numbers without using a temporary
variable.
Answer:
i=i+j;
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
j=i-j;
i=i-j;
Ques. 1 Which is the character array used to accept command line arguments?
A) char argv
B) char* argv[]
C) char argv[]
ls
D) char* argv
ia
Ques. 2 What is a dangling pointer?
er
Points to garbage value
Points to a function at
M
Both a and b
e
None
im
A) strstr
B)strcmp
T
C) strupr
Q
D) strchr
N
Ques. 4 Which of the following does not require to include math.h header file?
A) pow()
B) rand()
C)sqrt()
D) sinh()
Ques. 5 What is the task of pre-processor?
A) Expanding
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
B) Compiling
C) Linking
D) All of the above
Ques. 6 Which of the following is true?
A) realloc() can change the memory size of arrays
B) Unary operator works on only one operand
C) Struct and Union works in same way.
D) None of the above
Ques. 7 Which of this is used to skip one iteration:
ls
A) break
ia
B) continue
er
C) goto
D) return at
M
Ques. 8 Which address does a pointer to an array store:
e
A) Memory address of the first element of the array Don’t remember the other
im
options.
Pr
if(a==0.1)
Q
printf(“Yes”);
N
else
printf(“No”); Answer would be No.
Ques. 10 Another output based question which basically displayed the input
string in reverse pattern.
For example, ABRACADABRA was displayed as ARBADACARBA.
Telegram- https://t.me/placement_0
Telegram- https://t.me/placement_0
ls
ia
er
at
M
e
im
Pr
T
Q
N
Telegram- https://t.me/placement_0