0% found this document useful (0 votes)
36 views3 pages

Tcs Ninja 5text Paper

The document describes a TCS test with four sections - quantitative, verbal, programming language proficiency, and coding tests. It then provides answers to 10 questions related to C programming concepts like increment/decrement operators, comments, null characters, relational operators, data types, functions, and loops.

Uploaded by

Prashanth G
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views3 pages

Tcs Ninja 5text Paper

The document describes a TCS test with four sections - quantitative, verbal, programming language proficiency, and coding tests. It then provides answers to 10 questions related to C programming concepts like increment/decrement operators, comments, null characters, relational operators, data types, functions, and loops.

Uploaded by

Prashanth G
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

The TCS test Sampus seasons will have four sections:

1) Section-1 Quantitative Test

2) Section-2 Verbal Test (Test on Written English skills)

3) Section-3 Test on Programming Language Proficiency (based on ‘C’)

4) Section-4 Coding test (C Language)

Question 1: Use of an increment statement or decrement statement in C?

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.

Two types of increments are:

1. pre increment: (increment by 1 then print) and

2. post increment: (print then incremented value will be in buffer). Same thing will be with
decrement.

Question 2: In programs we place comment symbols on some codes instead of deleting it.
How does this aid in debugging?

Answer:

Placing comment symbols /* */ around a code, also referred to as commenting out , is a


way of isolating some codes that you think maybe causing errors in the program, without
deleting the code.

Question 3: What is the use of a ‘\0' character?

Answer:

This character is used primarily to show the end of a string value.


Question 4: What is the difference between the = symbol and == symbol?

Answer:

The = symbol is often used in mathematical operations. It is used to assign a value to a given
variable. On the other hand, the == symbol, also known as equal to or equivalent to, is a
relational operator that is used to compare two values.

Question 5: In C Programming, which of the following operators is incorrect and why? ( >=,
<=, <>, ==)

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.

Question 8: Can two or more operators such as \n and \t be combined in a single line of
program code?

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.

Question 9: When is the ‘void’ keyword used in a function?

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:
1
12
123
1234
12345

Answer:

for (a=1; a<=5; i++) {


for (b=1; b<=a; b++)
printf("%d",b);
printf("\n");
}

You might also like