TCS Coding
TCS Coding
Reverse a Number.
Palindrome.
Prime Number.
Leap Year.
Greatest among 10 numbers.
Fibonacci Series.
HCF / GCD.
Factorial.
Decimal to Binary & vice versa
Armstrong Number.
Area.
Swap 2 numbers.
Concatenate 2 strings.
LCM of Two Number using CLP.
Average of Two Numbers.
Sum of Digits of a number.
Binary to Decimal.
Decimal to Binary.
Factorial of a Number.
Square Root of Prime Number.
Square Root without square root.
Armstrong Number.
Odd-Even Number.
Binary to Octal.
Decimal to Octal.
Check Leap Year.
Area of Circle.
Checking Palindrome (Number).
Area of Triangle.
Checking Palindrome (String).
Reverse Digits of a Number.
Checking Prime or Not.
Find the 15th term of the series
0,0,7,6,14,12,21,18, 28
1,1,2,3,4,9,8,27,16,81,32,243,….
Q. Consider the following series: 1,1,2,3,4,9,8,27,16,81,32,243,64,729,128,2187…
This series is a mixture of 2 series – all the odd terms in this series form a geometric series and all the even terms
form yet another geometric series. Write a program to find the Nth term in the series.
The value N in a positive integer that should be read from STDIN. The Nth term that is calculated by the program
should be written to STDOUT. Other than value of n th term,no other character / string or message should be written
to STDOUT. For example , if N=16, the 16th term in the series is 2187, so only value 2187 should be printed to
STDOUT.
Q. 0,0,2,1,4,2,6,3,8,4,10,5,12,6,14,7,16,8
This series is a mixture of 2 series all the odd terms in this series form even numbers in ascending order and every
even terms is derived from the previous term using the formula (x/2)
The value n in a positive integer that should be read from STDIN the nth term that is calculated by the program
should be written to STDOUT. Other than the value of the nth term no other characters /strings or message should
be written to STDOUT.
For example if n=10,the 10 th term in the series is to be derived from the 9th term in the series. The 9th term is 8 so
the 10th term is (8/2)=4. Only the value 4 should be printed to STDOUT.
1. These three words will be read one at a time, in three separate line
2. The first word should be changed like all vowels should be replaced by $
3. The second word should be changed like all consonants should be replaced by #
4. The third word should be changed like all char should be converted to upper case
5. Then concatenate the three words and print them
Other than these concatenated word, no other characters/string should or message should be written to
STDOUT
For example if you print how are you then output should be h$wa#eYOU.
You can assume that input of each word will not exceed more than 5 chars
Q. Write a C program which will calculate the square root of a number without using math.h sqrt() function
and print that sqrt to the STDOUT as floating point number with exactly 2 decimal precision.
The following is a C program to check whether the given number is Armstrong number or not using
command line arguments.
Q1 : Write a C program to calculate the factorial of a non-negative integer N. The factorial of a number N
is defined as the product of all integers from 1 up to N. Factorial of 0 is defined to be 1. The number N is a
non-negative integer that will be passed to the program as the first command line parameter. Write the
output to stdout formatted as an integer WITHOUT any other additional text. You may assume that the
input integer will be such that the output will not exceed the largest possible integer that can be stored in
Q2: Write a C program to find the area of a triangle given the base and the corresponding height. The
values base and height are both positive integers passed to the program as the first and second
command line parameters respectively. Write the output to stdout formatted as a floating point number
rounded to EXACTLY 2 decimal precision WITHOUT any other additional text. Scientific format(such as
1.00E+5) should NOT be used while printing the output. You may assume that the inputs will be such that
the output will not exceed the largest possible real number that can be stored in a float type variable.
TC S C OD I NG QU ES TI O N S 2018 AND SO LU T IO N S
Binary to Decimal
Decimal to Binary
Factorial of a Number
Square Root of Prime Number
Square Root without sqrt.h
Armstrong Number
Odd Even Number
Binary to Octal
Decimal to Octal
Check Leap Year
Area of Circle
Area of Triangle
TC S P L AC EM E N T P AP E R S F O R TC S C OD I NG T E ST