0% found this document useful (0 votes)
103 views

TCS Coding

The document lists various math and programming problems including: reversing strings and numbers, checking for palindromes and prime numbers, calculating factorials, finding greatest common divisors, computing Fibonacci sequences, and more. It also includes two questions asking to write programs to find the nth term of two mixed series and provide sample inputs/outputs.

Uploaded by

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

TCS Coding

The document lists various math and programming problems including: reversing strings and numbers, checking for palindromes and prime numbers, calculating factorials, finding greatest common divisors, computing Fibonacci sequences, and more. It also includes two questions asking to write programs to find the nth term of two mixed series and provide sample inputs/outputs.

Uploaded by

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

Reverse a String.

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

Find the nth term of the series.

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.

You can assume that N will not exceed 30

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)

Write a program to find the nth term in this 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 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.

You can assume that the n will not exceed 20,000.

Q. . The program will recieve 3 English words inputs from STDIN

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.

Q. C program to find Armstrong number using Command line arguments

The following is a C program to check whether the given number is Armstrong number or not using
command line arguments.

Q. Command line program for odd even

Q. Command line program to convert binary to octal

Q. Command line program to convert Decimal to octal

Q. Command line program to check if a year is leap year or not

Q. Write a C program to find the area of a circle with radius provided.


The value of radius positive integer passed to the program as the first command line
parameter. 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.

Q. Command line argument to find area of a triangle

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

an int type variable.

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

 TCS Command Line Arguments – Fibonacci Series


 TCS Command Line Program to Swap two numbers
 TCS String Reversal Using Command Line Programming
 Greatest of Two Numbers using CLP
 LCM of Two Number using CLP
 Average of Two Numbers
 Sum of Digits of a number
 Area of a Triangle
COM M AN D LI N E AR G UM E N T S Q U ES TI O N S AS K E D I N TC 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

 Checking Palindrome (Number)


 Checking Palindrome (String)
 Checking Prime or Not
 Reverse Digits of a Number
 TCS Coding Questions – 3
 Prime Sum in a Given Range
 TCS Array Ascending Descending

You might also like