TCS Technical Pro Paid Paper-2
TCS Technical Pro Paid Paper-2
TCS Technical Pro Paid Paper-2
www.prepinsta.com
Also, don't share this PDF with anyone as if they will score good marks too your
percentile will get decreased
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.
● TCS Technical Pro Papers( Get as Much as 80% from here) - Buy Here
● TCS Aptitude Pro Papers( Get as Much as 80% from here) - Buy Here
● TCS Technical Pro Papers( Get as Much as 40% from here) - Buy Here
● TCS Aptitude Pro Papers( Get as Much as 50% from here) - Buy Here
● TCS Email Writing Pro Papers( Get as Much as 80% from here) - Buy Here
3. None of these
Correct Op: 4
1. Linked Lists
2. Array of structures
3. All of these
4. Binary Tree
Correct Op: 3
Q. Strings are character arrays. The last index of it contains the null-terminated
character
1. \t
2. \1
3. \0
4. \n
Correct Op: 3
1. String
2. Structure
3. Array
4. Files
Correct Op: 2
1. free();
2. malloc(variable_name, 0)
3. dealloc();
4. memalloc(variable_name, 0)
Correct Op: 1
Q. In the standard library of C programming language, which of the following
header file is designed for basic mathematical operations?
1. conio.h
2. stdio.h
3. math.h
4. Dos.h
Correct Op: 3
1. Pointer to integer
2. None of these
3. Pointer to pointer
4. Invalid declaration
Correct Op: 3
1. (underscore)
2. - (hyphen)
3. | (pipeline)
4. * (asterisk)
Correct Op: 1
Q9. All keywords in C are in
1. Uppercase letters
2. None of these
3. Lowercase letters
Correct Op: 3
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
++param;
int main(){
strcpy(string, "hello_World");
myfunc(&string);
myfunc(&string);
printf("%s\n", string);
1. hello_World
2. ello_World
3. lo_World
4. llo_World
Correct Op: 1
#include <stdio.h>
void main()
int k = 5;
int *p = &k;
a) 5 5 5
b) 5 5 junk
c) 5 junk junk
Explanations
Q. Which of the following statements about stdout and stderr are true?
Correct Op: D
Explanation -
a) False. b) Not by default. c) Not by default. d) True.
1) main() function should always be the first function present in a C program file
3) A void pointer can hold address of any type and can be typcasted to any type
A) 2,3
B) 1,2
C) 1,2,3
D) 1,2,3,4
Correct Op - A
Explanations
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:
B) all the variable declared inside the function automatically will be assigned
initial value of zero
C) It should be called only within the same source code / program file.
D) None of the other choices as it is wrong to add static prefix to a function
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.
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) {}
Answer: Option C
Explanation:
If the index of the array size is exceeded, the program will crash. Hence "option c"
is the correct answer. But the modern compilers will take care of this kind of
errors.
int (*ptr)[10];
Answer: Option B
Answer: Option C
Explanation:
The statement 'C' is correct. When we pass an array as a function argument, the
base address of the array will be passed.
int main()
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
return 0;
A.2, 1, 15
B.1, 2, 5
C.3, 2, 15
D.2, 3, 20
Answer: Option C
Explanation:
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
Step 6: printf("%d, %d, %d", i, j, m); It prints the value of the variables i, j, m
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.
6. Are the expressions arr and &arr same for an array of 10 integers?
A.Yes
B.No
Answer: Option B
Explanation:
Both mean two different things. arr gives the address of the first int, whereas the
&arr gives the address of array of ints.
7. Which of the fplowing statements should be used to obtain a remainder after
dividing 3.14 by 2.1?
Answer: Option C
Explanation:
This function is the same as the modulus operator. But fmod() performs floating
point divisions.
D.Internal
Answer: Option B
Explanation:
Internal pnkage-> means static variables and functions with file scope.
A.* (asterisk)
B.| (pipepne)
C.-(hyphen)
D._(underscore)
Answer: Option D
Explanation:
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
=> _foo42
=> _
=> QuUx
2 : int fun();
D.None of these
Answer: Option B
Explanation:
(B) -2
(C) 1
(D) Error
--2 is incorrect, // Invalid because lvalue is required to increment
main()
int i=-1;
-i; //No change in value of i
printf(“%d,%d”,i,-i);
(A) -1, 1
(B) -1, -1
(C) 1, 1
(D) 0, 1
main()
printf(“%d”,var);
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
}
Note: among logical operators logical NOT has right to left associativity , i.e . !
operator
a. 11,3,1,1 b. 11,2,0,1
c. 11,3,1,0 d. 10,2,0,1
a. Error b. 5,1
c. 2,1 d. 5,5
a. Error b. 5,1
c. 2,1 d. 5,5
a. Error b. hai
c. hello d. No output
a. True b. False
c. True False d. Error
a. True b. False
c. True False d. Error
a. Error b. HaiPrep
c. HaiInsta d. Prep
a. Error b. Prep
c. “”Insta d. Pr.ep
Predict the output of following code:
main()
{
if(printf(“O”, printf(“Two”))) / prints content of printf statement and takes
length of //the string for if case execution in this case its
4, So true
printf(“Prep”);
else
printf(“Insta”);
}
a. Error b. OTwoPrep
c. HaiInsta d. Prep
a. 400 b. 300
c. 100 d. Error
fun()
{
here:
printf(“\n I am here”);
}
a. Tom b. Jerry
c. Tom Jerry d. Error
main()
{
int a=2;
switch(a)
{
case 1: printf(“one”);
case 2: printf(“Two”); // Executable code ; No break statement
case 3: printf(“Three”);
default:printf(“Invalid option”);
}
}
a. onetwothree
b. Invalid option
c. one two
d. None of these
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
a. Error b. 10,10,10,10
c. GV,GV,GV,10 d. GV,GV,GV,GV
a. Error b. 195
c. 201 d. “ab”
Note:
A `%' is written.
No argument is converted.
The complete conversion specification is`%%'.
main()
{
printf(“%d”);
}
Note:
after 1st statement execution:
ks
nd
After 2 : k mi
After 3rd : ha i
a. Error b. 100
c. Garbage value d. 100100
Note:
First prints content of printf statement
Then prints its length in outer printf statement
Note: Output
Prep4
First Second Third
First Second Third 0.000000 0.000000 0.000000
First Second Third 676
a. 2000 b. 20
c. 4000 d. Garbage value
Note:
First prints content of printf for the case true
Then printf its length stored in x
a. 0 b. 1 c. 5 d. Error
a. 5 b. 3 c. 2 d. More than 5
Output: Errors
What would the output of this program be?
Will there be any error?
#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
Output: 50
Output: 9
#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
#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
#include<stdio.h>
void main(){
int x;
x=10,20,30; // Assigns first value to z i.e. 10
printf("%d",x);
return 0;
}
Output: 10
Output: false
int main()
{
signed char i=0;
for(; i >= 0; i++)
printf("%d\n", i);
getchar();
return 0;
}
main()
{
int a[20]={1,2,3};
printf(“%d”,sizeof(a));
}
a. 20 b. 6 c. Error d. 40 or 80
a. 1, 5 b. 1, 2 c. Error d. 1, 6
a. 2 b. h c. Error d. I
h→0
a→1
i→2
a. 1 b. Garbage c. Error d. 2
a. 7 b. 10 c. 9 d. 8
Output: 4
a. Error b. 1 c. 0 d. 6
a. 1, 2 b. 2, 2 c. 1, 1 d. Error
a. 49 b. 56 c. 64 d. Garbage value
int calc(int n)
{
int s, d;
if(n!=0)
{
d = n%10;
n = n/10;
s = d+calc(n);
}
else
return 0;
return s;
}
a. 6 6 b. 4 4 c. 2 8 d. Compilation error
a. 5
b. 0
c. Missing parenthesis in return statement
d. Error: re-declaration of p
a. 2 b. Compilation error
c. 1.300000 d. Garbage value
a. 1234,abcde
b. 12341234
c. Error
d. abcdeabcde
a. 13, 13
b. 13,0.000000
c. Error
d. 13, garbage value
}s1={1234,“abcde”};
main()
{
struct student s2={5678, “abcde”};
if(s1==s2) //invalid comparision struct instances
printf(“true”);
else
printf(“false”);
}
main()
{
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
#include<stdio.h>
float a;
double b;
a. printf("%f %lf", a, b)
b. printf("%f %Lf", a, b);
c. printf("%Lf %f", a, b);
d. None
Find the output:
#include<stdio.h>
int main()
{
float a=2.15529;
printf("%2.1f\n", a); //rounds decimal value to next higher digit
return 0;
}
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));
If a function’s return type is not explicitly defined then it’s default to ______ (In C).
A. int
B. float
C. void
D. Error
For passing command line argument the main function should be like _______
A. int main(char *argv[], int argc)
B. int main(int argc)
C. int main(char *argv[])
D. int main( int argc, char *argv[])
Options
A. 5
B. 1
C. 0
D. 3
D. enum
D. Long int
The following table provide the details of standard floating-point types with storage sizes
and value ranges and their precision −
{
while(x!=y) {
if(x>y)
return fg(x-y,y);
else
return fg(x,y-x);
}
return x; }
Options
A. 3
B. 6
C. 9
D. Error
Free()
Truncate()
delete()
release()
Till Page 46 F
Answer:
There are actually two ways you can do this. One is to use the increment operator
++ and decrement operator - -. For example, the statement x++ means to
increment the value of x by 1. Likewise, the statement x -- means to decrement the
value of x by 1.
Answer:
Answer:
Answer:
Answer:
<> 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:
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
32768, you can use long int instead. You can also use ‘unsigned int, assuming
you don’t intend to store negative values.
Answer: Yes, it’s perfectly valid to combine operators, especially if the need
arises.
For example: you can have a code like ‘printf (‘Hello\n\n\’World\’)’ to output the
text ‘Hello’ on the first line and ‘World’ enclosed in single quotes to appear on the
next two lines.
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.
Question 10: Write a loop statement that will show the following output:
12
123
1234
12345
Answer:
printf("%d",b);
printf("\n");
Question 1: How would you round off a value from 1.66 to 2.0?
A. ceil (1.66)
B. floor (1.66)
C. roundup (1.66)
D. Round to (1.66)
Answer: A
#include<stdio.h>
#include<math.h>
int main()
return 0;
// Output:
// Result : 2.000000
// Result : 2.000000
// Result : 1.000000
// Result : 1.000000
Question 2: What will be the output of the program?
#include<stdio.h>
int X=40;
int main()
int X=20;
printf("%d\n", X);
return 0;
A.20
B.40
C.Error
D.No Output
Answer: A
Whenever there is conflict between a local variable and global variable, the local
variable gets priority.
A. True
B. False
Answer: A
True, we can use long double; if double range is not enough.
Double = 8 bytes.
A.True
B. False
Answer: A
True,
float = 4 bytes.
Double = 8 bytes.
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
declaration in the function.
A. True
B. False
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 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
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
Answer: A
True, we can find the size of short integer and long integer using the sizeof()
operator.
A. True
B. False
Answer: B
A. True
B. False
Answer: A
A. True
B. False
Answer: Option B
scanf(%d,whatnumber);
Answer:
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
address of the variable name. This is a common mistake for programmers, often
leading to logical errors.
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
number. The number after the decimal point sets the number of decimal places, in
this case, it’s 2 decimal spaces.
Answer:
Answer:
Binary trees are actually an extension of the concept of linked lists. A binary tree
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.
Answer:
4. C uses the top-down approach while JAVA uses the bottom-up approach.
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.
Answer:
Answer:
Question 10: What are macros? What are its advantages and disadvantages?
Answer:
Macros are processor directive which will be replaced at compile time.
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.
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.
Answer:
Object is a software bundle of variables and related methods. Objects have state
and behaviour.
Answer:
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.
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:
a specific block of memory within the computer to hold the value of that variable.
Answer:
A Null pointer has the value 0. Void pointer is a generic pointer introduced by
ANSI. Generic pointer can hold the address of any data type.
Answer:
return nX + nY;
Answer:
Answer: The idea behind inline functions is to insert the code of a called function
at the point where the function is called. If done carefully, this can improve the
application's performance in exchange for increased compile time and possibly
(but not always) an increase in the size of the generated binary executables.
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.
Question 1: What is the difference between an array and a list?
Answer:
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.
Answer:
Arrays are a group of similar data types but Structures can be group of different
data types.
Answer:
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
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,
Operating System,
Numerical Analysis,
Graphics,
Answer:
Answer:
Answer:
Argument vector
Environment vector
Answer:
Answer:
Create two pointers, each set to the start of the list. Update each as follows:
while (pointer1) {
pointer1 = pointer1->next;
if (pointer1 == pointer2) {
print ("circular\n");
Question 10: Write a program to swap two numbers without using a temporary
variable.
Answer:
i=i+j;
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[]
D) char* argv
Ques. 2 What is a dangling pointer?
Points to garbage value
Points to a function
Both a and b
None
Ques. 3 Which is not a string function?
A) strstr
B)strcmp
C) strupr
D) strchr
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
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:
A) break
B) continue
C) goto
D) return
Ques. 8 Which address does a pointer to an array store:
A) Memory address of the first element of the array Don’t remember the other
options.
Ques. 9 Predict the output:
float a = 0.1;
if(a==0.1)
printf(“Yes”);
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.
1. The function ____ obtains block of memory dynamically.
a) calloc
b) malloc
d) free
a) scanf
b) Files
c) Command-line
a) char
b) int
C. char *
a) Static area
b) Stack area
c) Heap area
a) 1 bit
b) 2 bits
c) 1 Byte
d) 2 Bytes
a) char
b) short
c) unsigned int
d) long
a) remove(p);
b) delete(p);
c) free(p);
d) terminate(p);
void main()
int x = 97;
int y = sizeof(x++);
a) x is 97
b) x is 98
c) x is 99
a) strlen()
b) strcpy()
c) strptr()
d) strupr()
3. which of the below function is NOT declared in math.h ?
a) and()
b) pow()
c) exp()
d) acos()
a) In a Queue
b) In stack Memory
c) In hard Disk
d) In heap Memory
5. while declaring parameters for main, the second parameter argv should be
declared as
a) char argv[]
b) char argv
c) char ** argv[]
d) char * argv[]
a) Declarations
b) Implementations
c) Prototypes
a) long int
b) double
d) float
#include <stdio.h>
float f = 0.1;
if (f == 0.1)
printf("YES\n");
else
printf("NO\n");
return 0;
Output: NO
d) to flush a file
11. which of the following is used locate the end of the file ?
12. A code will be given and you will be asked which header is missing??
#include<stdio.h>
int main()
{
int x,y;
for(x=5;x>=1;x--)
for(y=1;y<=x;y++)
printf("%d\n",y);
a) 11
b) 13
c) 15
d) 10
a) feof()
b) EOF
a) int
b) float
c) void
d) error
a) Disk
b) Stack
c) Heap
d) Register
#include<stdio.h>
int main()
int i;
for(i=0;i<5;i++)
printf("Hello\n");
a) 0
b) 1
c) 3
d) 5
6. What is dangling pointer?
b) points to function
c) Both A and B
d) None of these
8. What is recursion ?
a) looping
a) Enum
c) Long int
d) double
#include<stdio.h>
int main(void)
int i;
for(i=0;i<5;i++);
printf("hello");
a) Compilation error
b) Runtime error
c) 4
d) 1
Ques. Which of this is used to skip one iteration:
A) break
B) continue
C) goto
D) return
Ques. Which of the following does not require to include math.h header file?
A) pow()
B) rand()
C)sqrt()
D) sinh()
A. float
B. double
D. Long int
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
Ques. Predict the output of following code:
main()
int a=10,x;
x= a-- + ++a;
printf(“%d”,x);
A) 19
B) 20
C) 22
D) 23
main()
printf(“%d”, sizeof('a'));
//same as → sizeof(97)
A) 2 or 4 ---
B) 1 or 3
C) Garbage value
D) ASCII value of a
Explaination:
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
main()
int a=b=c=d=10;
printf(“%d,%d,%d,%d”,a,b,c,d);
A) Error
B) 10,10,10,10
#include<stdio.h>
int main()
\\missing statement
{
if(n>=1)
return n*fact(n-1);
else
return 1;
A) printf(“%ll\n",fact(5));
B) printf("%u\n",fact(5));
C) printf("%d\n",fact(5));
D) printf("%ld\n",fact(5));
Ques. If a function’s return type is not explicitly defined then it’s default to ______
(In C).
A) int
B) float
C) void
D) Error
#include<stdio.h>
int main()
int i;
for(i=0;i<5;i++)
printf("Hello\n");
}
A) 5
B) 1
C) 0
D) 3
a) Subscripted variable
b) Collective array
c) Ordinary variable
2) Till the array elements are not given any specific value, they are supposed to
contain all ____________
a) Zero
b) Garbage value
c) One
a) Data type
b) Dimension
c) name
d) Data type and Dimension
b) No output
d) none of these
int main()
int b[4]={5,1,32,4};
int k,l,m;
k=++b[1];
l=b[1]++;
m=b[k++];
a) 2, 2, 4
b) 3, 2, 32
c) 3, 2, 4
d) 2, 3, 32
Ans--> Here, ++b[1] means that firstly b[1] will be incremented so, b[1]=2 then
assigned to k i.e. k=2.
b[1]++ means firstly b[1] will be assigned to variable l i.e. l=2, Then value stored in
b[1] will be incremented i.e. b[1]=3.
b[k++] means first b[k] will be assigned to m i.e. m=32, then value of k will be
incremented i.e. k=3.
6) What will be output of the following program where c=65474 and int=2 bytes.
int main()
int c[3][4]={2,3,1,6,4,1,6,2,2,7,1,10};
return 0;
}
a) 65482, 65498
b) 65476, 65476
c) 65476, 65498
d) No output
{2,3,1,6};
{4,1,6,2};
{2,7,1,10}
};
c+1 means c is base address i.e. address of 1st one Dimensional array and on
incrementing it by 1 means it points to 2nd one 2 Dimensional array.
But, when we are writing &c, that means address of this whole array i.e. address
of next new array.
int main()
int a[5],i=0;
while(i<5)
a[i]=++i;
for(i=0;i<5;i++)
printf("%d,",a[i]);
a) garbage value,1,2,3,4
b) 1,2,3,4,5
c) Error
d) Program crash
Ans--> firstly right side of any expression is evaluated, then the left side is
evaluated. So, here ++i will be evaluated at first, then a[i].
int main()
return 0;
a) 16 bytes, 4 bytes
b) 4 bytes, 4 bytes
c) 8 bytes, 4 bytes
d) None of these
=4 * 4 bytes
=16 bytes
= 4 bytes
a) int fun(arr)
d) None of these
Ans-->int fun(int arr[]) and int fun(int arr[0]) are equivalent. Both are prototype for
function fun(), that accepts one integer array as parameter and return an integer
value.
a) second
b) first
c) both
d) none of these
int arr[][3]={12,34,33,45,56,73};
a) Call by reference
b) call by value
d) Both a and c
int main()
{
int arr[4]={3,4,5,6};
int k[4];
k=arr;
printf("%d\n",k[1]);
b) 4
c) No output
d) Program crashes
#include <stdio.h>
void main()
static int i;
a) 0
b) 1
c) Garbage Value
#include <stdio.h>
int *i;
int main()
if (i == NULL)
printf("true\n");
return 0;
a) true
d) Nothing
#include <stdio.h>
static int i;
void main()
{
int i;
a) 0
b) Garbage Value
d) Nothing
#include <stdio.h>
static int x = 5;
void main()
x = 9;
int x = 4;
printf("%d", x);
a) 9
b) 4
c) 5
d) 0
d) Within the block it appears & Within the blocks of the block it appears
a) stack
b) queue
c) priority queue
d) random
a) enum
b) union
c) auto
d) volatile
a) stack
b) data segment
c) register
d) heap
#include <stdio.h>
int main()
int *q = &i;
*q = 11;
b) 10 10
c) 11 11
a) true
b) false
a) stack
b) registers
c) heap
d) main memory
#include <stdio.h>
void main()
m();
void m()
printf("SimpleWay2Code");
}
}
a) SimpleWay2Code
c) Nothing
d) Varies
#include <stdio.h>
void main()
static int x = 3;
x++;
if (x <= 5)
printf("hello");
main();
b) hello
c) Infinite hello
d) hello hello
3. The value obtained in the function is given back to main by using ________
keyword?
a) return
b) static
c) new
d) volatile
int func(int);
double func(int);
int func(float);
a) int
b) float
c) double
#include <stdio.h>
void foo()
return 1;
void main()
int x = 0;
x = foo();
printf("%d", x);
a) 1
b) 0
c) Runtime error
#include <stdio.h>
void main()
int k = m();
printf("%d", k);
}
void m()
printf("hello");
a) hello 5
b) Error
c) Nothing
d) Garbage value
#include <stdio.h>
int *m()
int *p = 5;
return p;
void main()
int *k = m();
printf("%d", k);
}
a) 5
b) Junk value
c) 0
d) Error
#include<stdio.h>
int main()
int i=1;
if(!i)
printf("SimpleWay2Code,");
else
i=0;
printf("C-Program");
main();
return 0;
#include<stdio.h>
int main()
printf("SimpleWay2Code");
main();
return 0;
A. Infinite times
B. 32767 times
C. 65535 times
#include <stdio.h>
int a;
void main()
if (a)
printf("Hello");
else
printf("world");
a) Hello
b) World
#include <stdio.h>
void main()
int a = 5;
if (true);
printf("hello");
c) No Output
d) Depends on Compiler
3. The output of the code below is
#include <stdio.h>
void main()
int a = 0;
if (a == 0)
printf("hi");
else
printf("hello");
a) hi
c) hello
d) hihello
4. The following code ‘for(;;)’ represents an infinite loop. It can be terminated by.
a) break
b) exit(0)
c) abort()
5. The correct syntax for running two variable for loop simultaneously is.
for (j = 0; j < n; j += 5)
6. Which for loop has range of similar indexes of ‘i’ used in for (i = 0;i < n; i++)?
#include <stdio.h>
void main()
{
int x = 0;
printf("Hello");
c) Nothing
d) Varies
#include <stdio.h>
void main()
double x = 0;
printf("Hello");
#include <stdio.h>
int main()
do
while (0);
printf("Outside loop\n");
Outside loop
c) Outside loop
d) Infinite loop
#include <stdio.h>
int main()
int i = 0;
do {
i++;
11. Which of the following cannot be used as LHS of the expression in for (exp1
;exp2 ; exp3) ?
a) Variable
b) Function
c) typedef
d) macros
b) return
c) exit
a) do-while
b) if-else
c) for
d) while
14. Which keyword is used to come out of a loop only for single iteration?
a) break
b) continue
c) return
#include <stdio.h>
void main()
int i = 0;
if (i == 0)
printf("Hello");
break;
b) Hello
c) Varies
a) int __v1;
b) int __1v;
c) int __V1;
d) None
Ans:d
a) int _v1;
b) int v_1;
c) int 1_v;
d) int _1v
Ans:c
Ans:c
a) int number;
b) float rate;
c) int variable_count;
d) int $main;
Ans:d
Ans:c
#include <stdio.h>
int main()
int main = 5;
printf("%d", main);
return 0;
a) compile-time error
b) run-time error
Ans:c
Explanation:A C program can have same function name and same variable name.
a) friend
b) true
c) volatile
d) export
Ans: c
Explanation:volatile is C keyword
8. The format identifier ‘%i’ is also used for _____ data type?
a) char
b) double
c) float
d) int
Ans:d
Explanation:Both %d and %i can be used as a format identifier for int data type.
9. Which of the following is a User-defined data type?
Answer:d
a) Basic datatype of C
b) Qualifier
Ans:c
#include <stdio.h>
int main()
chr = 128;
printf("%d\n", chr);
return 0;
a) 128
b) -128
Ans:b
a) 4 Bytes
b) 8 Bytes
d) Cannot be determined
Ans:c
a) int
b) struct
c) float
d) double
Ans:b
Explanation:Since the size of the structure depends on its fields, it has a variable
size.
#include <stdio.h>
int main()
{
float x = 'a';
printf("%f", x);
return 0;
a) 97.000000
c) a.0000000
d) a
Ans:a
Explanation:Since the ASCII value of a is 97, the same is assigned to the float
variable and printed.
a) MultiDimensional Array
b) Jagged Array
c) 2-Dimensional Array
b)256 characters
d)128 characters
a) argc
b) argc * 2
c) argc - 1
d) argc + 1
a)File Name
b)Program Designation
d)Program Name
a)Array of pointers
d)Array of Strings
#include<stdio.h>
int j;
printf("%d", j);
return 0;
}
a)Error
b)3
c)Garbage Value
d)None of these
Ans--> Here, argv[1], argv[2] and argv[3] are of type String. So, we have to convert
String to integer before performing arithmetic operation.
d) None of these.
a) Number of Arguments
b) Number of Arguments - 1
c) Number of Arguments + 2
d) Number of Arguments + 1
11) What will be output of the following program if argument passed to command
lines are : prog 1 4 2
#include<stdio.h>
while(argc--)
printf("%s\n",argv[argc]);
return 0;
a) 2 4 1
b) Garbage-value 2 4 1
c) Garbage-value 2 4 1 prog
d) Infinte Loop
12) What will be output of the following program if argument passed to command
lines are : demo one two three
#include<stdio.h>
printf("%c\n",**+argv);
return 0;
}
a) n
b) o
c) t
Ans--> Here, char * argv[ ] denotes Array of Pointers. So, argv[ ] holds the address
of the command line argument passed. ++argv denote the address of next
location, which holds the address of the 2nd argument.
*++argv denote the value stored at that address i.e. the address of the 1st
character of the 2nd argument and **++argv itself denote the character 'o' .
13) What will be output of the following program if argument passed to command
lines are : demo friday
#include<stdio.h>
printf("%c",*++argv[1]);
return 0;
a) r
b) f
c) i
d) d