C interview Programs for TCS

Answers were Sorted based on User's Feedback



C interview Programs for TCS..

Answer / subrahmanyam kesana...........

C Programmes



******* Fibonacci series **********

#include<stdio.h>
main()
{
Int n1=0,n2=1,n,counter,fib;
Printf(“enter the length of fibonacc series”);
Scanf(“%d”,&n);
Printf(“the Fibonacci series is:”);
Printf(“%d%d”,n1,n2);
for(counter=1;counter<=n-2;counter++)
{
Fib=n1+n2;
Printf(“%d”,fib);
N1=n2;
N2=fib;
}
}


******* To generate prime number **********

#include<stdio.h>
main()
{
int n,I,j,b;
printf(“enter the value of n”);
scanf(“%sd”,&n);
for(i=1;i<=n;i++)
{
b=0;
for(j=1;j<=i;j++)
{



If(i%j==0)
{
b=b+1;
}
}
If(b===2)
{
Printf(“%d”,i);
}
}
}




*********Calculating sum of the digits********

#include<stdio.h>
main()
{
int n,k,sum=0;
printf(“enter the number that is to be added”);
scanf(“%d”,&n);
while(n!=0)
{
K=n%10;
Sum=sum+k;
N=n/10;
}
Printf(“sum of digits is%d”,sum);
}




********To reverse a number ********

#include<stdio.h>
main()
{
int n,k,rev=0;
printf(“enter the number that is to be reversed”);
scanf(“%d”,&n);
while(n!=0)
{
K=n%10;
rev=rev*10+k;
N=n/10;
}
Printf(“reverse number is%d”,rev);
}



*********Factorial number********

#include<stdio.h>
main()
{
Int num,factorial=1;
Printf(“enter the number”);
Scanf(“%d”,&num);
While(num>0);
{
Factorial=factorial*num;
Num=num-1;
}

Printf(“Factorial is%d”,factorial);
}



********Finding even & odd numbers********

#include<stdio.h>
main()
{
Int n,I;
printf(“enter the values of n”);
scanf(“%sd”,&n);
for(i=1;i<=n;i++)
{
If(i%2==0)
Printf(“%d is even”);
Else
Printf(“%d is odd”);
}
}


********Palindrome number********

include<stdio.h>
main()
{
Int n,n1,r,sum=0;
printf(“enter the number”);
scanf(“%sd”,&n);
n1=n;
while(n>0)
{
r=n%10;
sum=sum*10+k;
n=n/10;
}
If(n1==sum)
Printf(“it is palindrome”);
else
Printf(“it is not a palindrome”);

}



********Armstrong number********

#include<stdio.h>
main()
{
Int n,n1,r,sum=0;
printf(“enter the number”);
scanf(“%sd”,&n);
n1=n;
while(n>0)
{
r=n%10;
sum=sum+(r*r*r);
n=n/10;
}
If(n1==sum)
Printf(“it is Armstrong number”);
else
Printf(“it is not a Armstrong number”);

}


Is This Answer Correct ?    17 Yes 1 No

C interview Programs for TCS..

Answer / guest

main
{
printf("value");
scanf("%d",&s);
}

Is This Answer Correct ?    6 Yes 22 No

Post New Answer

More Placement Papers Interview Questions

access specifiers in set/get method

1 Answers   Infoline,


TISL PLACEMENT PAPERS -------------- Placement Paper 10

1 Answers   TISL,


PHILIPS PLACEMENT PAPERS ________ Placement Paper 2

1 Answers   Philips, Samsung,


electrical

1 Answers   Tata Chemicals,


L&T Infotech Interview - 13 Feb 2007

1 Answers   L&T,






placement papers

3 Answers   CMS,


Interview Experience

1 Answers   Consagous,


COGNIZANT TECHNOLOGY SOLUTION placement PAPER

1 Answers   Cognizant, CTS,


Syntel Campus Interview In Bangalore HKBKCE (April 7 2007)

22 Answers   HCL, Syntel, TCS, Torry Harris,


Couls anyone please tell me the kind of questions which will be asked for ONGC Programming discipline.No idea about the programming questions.Which programming language will be asked...please do send a previous placement paper for programming as well

3 Answers   ONGC,


I-GATE PLACEMENT PAPERS ---------placement paper -1

3 Answers   iGate,


HUGHES PLACEMENT PAPERS ------ Placement Paper 2

1 Answers   Hughes,


Categories