TCS Programming Questions with Answers
TCS Programming Test Questions are not like a general Coding Round Questions with Solutions it is all together different from C programming. We have analysed over 100+ TCS Programming Questions they use Command Line Programming in the Programming Section of the test. Below you will find TCS Programming Round Questions, TCS Coding Questions that are asked constantly in TCS Placement Papers Programming, programming Test of TCS Placement Coding Questions, TCS C Coding Questions, TCS C Programming Questions, TCS Coding Section, TCS C Programming Questions and Answers.
Get all the questions asked Today in TCS here –
TCS Ninja Live Questions Dashboard
TCS Placement Papers Programming

Online Classes
- Free Paid Materials also given
- Click here to join Online Live Class
TCS Paid Material –
No Online Class in this, in Online class you will get preparation paid materials access also, but if you just want materials then you can buy the ones below –
- TCS Aptitude Preparation Paid Materials
- TCS Coding Preparation Paid Materials
- TCS Verbal English Preparation Paid Materials
- TCS Programming MCQ Preparation Paid Materials
- TCS email Writing Preparation Paid Materials
or
Prices increase for Paid materials in
Free Materials
Question 0
Find the 15th term of the series?
0,0,7,6,14,12,21,18, 28
Please add the answer in the comment section below.
Question 1
Find the nth term of the series.
1,1,2,3,4,9,8,27,16,81,32,243,….
#include
#include
int three(n)
{
int x,i;
for(i=0;i<100;i++)
{
x=pow(3,i);
if(i==n)
printf(“%d”,x);
}
}
int two(n)
{
int x,i;
for(i=0;i<100;i++)
{
x=pow(2,i);
if(i==n)
printf(“%d”,x);
}
}
int main()
{
int n;
scanf(“%d”,&n);
if(n%2==0)
three(n/2);
else
two(n/2+1);
}
Question – 2
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.
#include
#include
int main() {
//code
int n;
scanf(“%d”, &n);
if(n % 2 == 1)
{
int a = 1;
int r = 2;
int term_in_series = (n+1)/2;
int res = pow(2, term_in_series – 1);
printf(“%d “, res);
}
else
{
int a = 1;
int r = 3;
int term_in_series = n/2;
int res = pow(3, term_in_series – 1);
printf(“%d “, res);
}
return 0;
}
Extra Questions without Solutions and Options that students couldn’t remember, please add solutions in the comment section below –
- Given a series whose even term creates a separate geometric series and odd term creates another geometric series . Prog in any language to find the nth term. Where u may consider that n not greater dan 30.
- 1,1,2,2,4,4,8,8,16,16 also this code
Solutions to one of the problem discussed above –
#include
#include
#includelong long int power(long long int a,long long int b ){
long long int i,ans=1;
for(i=0;i<b;i++)
{
ans=ans*a;
}
return ans;
}
// long long int three(long long int n){
// return pow(3,n);
// }
// long long int two(long long int n){
// return pow(2,n);
// }
int main()
{
clrscr();
long long int i,nth,a[1000];
scanf(“%lld”,&nth);
for(i=0;i<nth;i++)
{
if(i%2==0)
{
a[i]=power(2,i/2);
}
if(i%2==1)
{
a[i]=power(3,(i/2)+1);
}
}
printf(“%lld “,a[nth-1]);
return 0;
}
Question 3
Consider the below series :
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.
Code:
#include
#include
int main() {
//code
int n;
scanf(“%d”, &n);
if(n % 2 == 1)
{
int a = 1;
int r = 2;
int term_in_series = (n+1)/2;
int res = 2 * (term_in_series – 1);
printf(“%d “, res);
}
else
{
int a = 1;
int r = 3;
int term_in_series = n/2;
int res = term_in_series – 1;
printf(“%d “, res);
}
return 0;
}
Solution not Available in other languages as of now- Please add in comments
Question 4
0,0,2,1,4,2,6,3,8,4,10,5,12,6….
#include
int main()
{
int i=3,n;
printf(“enter nth term”);
scanf(“%d”,&n);
int a[n+1];
a[1]=0;
a[2]=0;
while(i<=n)
{
if(i%2==0)
a[i]=a[i-2]+1;
else
a[i]=a[i-2]+2;
i++;
}
printf(“%d”,a[n]);
}
Question 5
1. The program will recieve 3 English words inputs from STDIN
- These three words will be read one at a time, in three separate line
- The first word should be changed like all vowels should be replaced by $
- The second word should be changed like all consonants should be replaced by #
- The third word should be changed like all char should be converted to upper case
- 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
Write Code for this
#include
#include
#include
int main()
{
char *str1=malloc(sizeof(char)*256);
char *str2=malloc(sizeof(char)*256);
char *str3=malloc(sizeof(char)*256);
printf(“ENter 3 words : “);
scanf(“%s%s%s”,str1,str2,str3);
int p1=strlen(str1);
int p2=strlen(str2);
int p3=strlen(str3);
for(int i=0;i<p1;i++)
{
if(str1[i]==’a’||str1[i]==’e’||str1[i]==’i’||str1[i]==’o’||str1[i]==’u’)
{
str1[i]=’
Free Materials
We have a lots of free materials don’t worry. Check them out below.
- Once finished with this Coding section, visit our Main TCS Dashboard here for other sections like Aptitude, Coding Questions, Command Line Programming etc.
TCS Coding Section used to be based on Command Line Argument based Coding Questions it is available no where else on the internet. We will try help you with learning command line argument based coding for TCS.
From this year there is no command Line programming but you have to use C, C++, Java, Python and Perl. We have the latest set of questions for the new pattern
Question 0
Find the nth term of the series.
1,1,2,3,4,9,8,27,16,81,32,243,….
#include<stdio.h>
#include<math.h>
int three(n)
{
int x,i;
for(i=0;i<100;i++)
{
x=pow(3,i);
if(i==n)
printf("%d",x);
}
}
int two(n)
{
int x,i;
for(i=0;i<100;i++)
{
x=pow(2,i);
if(i==n)
printf("%d",x);
}
}
int main()
{
int n;
scanf("%d",&n);
if(n%2==0)
three(n/2);
else
two(n/2+1);
}
TCS Coding Questions and Solutions
Languages allowed –
- C
- C++
- Command Line in C
- Java
- Perl
- Python
Platform will be eclipse based compiler. You can code on onlinegdb.com. All your codes working on this website would run perfectly in TCS compiler.
Non Command Line Programs
- TCS Coding Question – 1
- TCS Coding Question – 2
- TCS Coding Question – 3
- TCS Coding Question – 4
- TCS Coding Question – 5
Command Line Programs (Not in Syllabus anymore
Paid Material
According to the latest syllabus of TCS- TCS Coding Materials – 1
- TCS Coding Materials – 2
- TCS Coding Materials – 3
- TCS Coding Materials – 4
- TCS Coding Materials – 5
- TCS Coding Materials – 6
- TCS Coding Materials – 7
- TCS Coding Materials – 8
- TCS Coding Materials – 9
- TCS Coding Materials – 10
- TCS Coding Materials – 11
- TCS Coding Materials – 12
- TCS Coding Materials – 13
- TCS Coding Materials – 14
- TCS Coding Materials – 15
- TCS Coding Materials – 16
- TCS Coding Materials – 17
- TCS Coding Materials – 18
- TCS Coding Materials – 19
- TCS Coding Materials – 20
- TCS Coding Materials – 21
- TCS Coding Materials – 22
- TCS Coding Materials – 23
- TCS Coding Materials – 24
- TCS Coding Materials – 25
- TCS Coding Materials – 26
- TCS Coding Materials – 27
- TCS Coding Materials – 28
- TCS Coding Materials – 29
- TCS Coding Materials – 30
- TCS Coding Materials – 31
- TCS Coding Materials – 32
- TCS Coding Materials – 33
- TCS Coding Materials – 34
- TCS Coding Materials – 35
- TCS Coding Materials – 36
- TCS Coding Materials – 37
- TCS Coding Materials – 1
- TCS Coding Materials – 2
- TCS Coding Materials – 3
- TCS Coding Materials – 4
- TCS Coding Materials – 5
- TCS Coding Materials – 6
- TCS Coding Materials – 7
- TCS Coding Materials – 8
- TCS Coding Materials – 9
- TCS Coding Materials – 10
- TCS Coding Materials – 11
- TCS Coding Materials – 12
- TCS Coding Materials – 13
- TCS Coding Materials – 14
- TCS Coding Materials – 15
- TCS Coding Materials – 16
- TCS Coding Materials – 17
- TCS Coding Materials – 18
- TCS Coding Materials – 19
- TCS Coding Materials – 20
- TCS Coding Materials – 21
- TCS Coding Materials – 22
- TCS Coding Materials – 23
- TCS Coding Materials – 24
- TCS Coding Materials – 25
- TCS Coding Materials – 26
- TCS Coding Materials – 27
- TCS Coding Materials – 28
- TCS Coding Materials – 29
- TCS Coding Materials – 30
- TCS Coding Materials – 31
- TCS Coding Materials – 32
- TCS Coding Materials – 33
- TCS Coding Materials – 34
- TCS Coding Materials – 35
- TCS Coding Materials – 36
- TCS Coding Materials – 37
TCS Coding Round Questions in Test Pattern and Syllabus
- Number of Questions – 1
- Total time to Solve – 20 mins
- Difficulty Level – 1 Easy Questions
- Cut-off – Solve 1 question completely or partial output
Though command Line Programming is not there you should study it for C MCQ section as 1-2 MCQ would be there for command Line program.
TCS C Programming Questions Basics
- Keywords like getc, scanf, getch, getchar etc can not be used.
- Instead we use command line arguments to fetch values.
TCS Coding Section
Before reading further for TCS Coding Round Questions, I will suggest not to freak out if you don’t understand in first go. Read everything once and then when you read again things will start to make sense. It is the best resource on the internet to know about TCS command line Argument Type Questions and TCS C Programming Questions and Answers.
TCS Programming Test Facts and Questions
TCS Coding Round Questions Topics | Difficulty in TCS Coding Round | Probability of asking in TCS Coding Test | Time to solve | |
---|---|---|---|---|
LCM HCF TCS Coding Questions | Medium | 10 | 20 mins | |
Swapping and Reversal TCS Coding Round Questions | Hard | 20 | 20 mins | |
Factorial and Series | Medium | 20 | 20 mins | |
Operations on Numbers in TCS Coding Test | Easy | 30 | 20 mins | |
Misc | Medium – Hard | 20 | 20 mins |
TCS Coding Questions with Answers
Let us consider this, if you wanted to write a basic C program then you would’ve written a main function that would’ve looked like in compiler for TCS Coding Round Questions –
int Main(){
// some code
}}
tcs placement coding questions
However in command line arguments we write like this –
int main(int argc, char *argv[]){
- argc – It is known as Argument Count and as clear from the name it stores the Count of number of Arguments.
- argv[] – Pointer, contains location of all the values(arguments).
- *argv[] – Array of values of all the arguments.
- They are parameters/arguments supplied to the program when it is invoked.
Thus, now we have two things
- Total Count of number of Arguments.
- All the values/pointer location of arguments stored in an array.
Now, you will need one more thing i.e. atoi();
- atoi(); – Converts string into int and atoi(argv[i]); will give the value of argument at ith location in int type format.
Now you can use an int val = atoi(argv[i]); to store the value and then print it with printf(); function.
Check out this video Below to learn how to Solve Command Line Programming.
Quick Facts
argv[0] contains the name, not the value so –
- All for loops must start from i=1.
- You must use the following condition
if(argc == 1){
// do nothing since, there are no arguments, maybe ask for arguments?
}else{
// code to apply logic and print values in TCS Coding Round Questions.
}
- provided+1 +1 for file.exe
- argv[argc] is a NULL pointer.
- argv[0] holds the name of the program.
- argv[1] points to the first command line argument and argv[n] points last argument.
tcs programming questions and Answers
TCS Programming Questions with Answers Type | No of times asked in TCS Programming Test | Importance for Programming Round | Difficulty in TCS C Programming Questions |
---|---|---|---|
TCS C Programming Questions on String Reversal | 14 | Low | Very High |
Average of two Numbers | 39 | Medium | Medium |
TCS Placement Papers Programming LCM of two Numbers | 51 | High | Medium |
HCF/GCD Question | 66 | High | Medium |
// Program to print all value of
// command line argument
// once we get the value from command
// line we can use them to solve our problem.
#include // this is used to print the result using printf
#include // this is used for function atoi() for converting string into int
// argc tells the number of arguments
// char *argv[] is used to store the command line
arguments in the pointer to char array i.e string format
int main(int argc, char *argv[])
{
// means only one argument exist that is file.exe
if (argc == 1) {
printf(“No command line argument exist Please provide them first \n”);
return 0;
} else {
int i;
// actual arguments starts from index 1 to (argc-1)
for (i = 1; i < argc; i++) {
int value = atoi(argv[i]);
// print value using stdio.h library’s printf() function
printf(“%d\n”, value);
}
return 0;
}
}
TCS Programming Test Based FAQ’s
Ques. What is the level of difficulty of the question asked in TCS programming round?
Ans. They are easy but you need to have good grip over basic C/C++ input/output or pattern based programs.
Logics like Recursion, For loops, If loops etc
Ques. What languages can we use in TCS Coding Round Questions?
Ans. In TCS Coding Round Questions currently you can only use C/C++ and Java for coding in TCS based Compiler that is mostly GCC type of compiler.
Ques. Is PrepInsta enough to prepare for TCS Coding Round and Questions asked in the exams?
Ans. Yes, it is the best resource out there in the internet to prepare for TCS Coding section paper.
Rules for TCS Coding Round Questions Section:
There is only one question for 20 minutes.
• It has 10 attempts(We can compile only 10 times).
• We must start our code from the scratch.
• The coding platform is divided into two, one for writing the code and other for output. We should write the whole
program.
• We can’t use any input functions like scanf(), getch(), getchar().
• The input to be provided should be read as command line arguments.
We must only print exact output.
• Output must not be re-framed by extra words.
• If there is any error, the error will be shown in the output dialog box.
• The errors are clearly mentioned.
• If there are no errors, a message like “compiled successfully” will be printed.
• Along with that they will mention four test cases are ‘passed’ or ‘failed’. They are indicated like private and public test cases. They have not mentioned what is the test case, which is difficult to understand.
Don’t Compile again and again since compiler takes 25 seconds and each time you compile 25 seconds will become lesser in the time you have to code in TCS Placement Papers Programming.
Ques. What kind of TCS C Programming Questions are asked in the exam?
Ans. Instead of TCS C Programming Questions and Answers they are now using Command Line Programming instead of TCS C Programming Questions.
Ques. How to clear the TCS coding round?
Ans. First you must learn command line programming from our coding dashboard and then try sample questions given on the dashboard to know how to clear the tcs coding round and TCS C Programming Questions and Answers
Ques. What are some other websites where we can find more questions?
Ans. You can find more questions on MyGeekMonkey website here – http://mygeekmonkey.com/tcs-coding-questions.html




