C language interview questions solution for freshers beginners placement tricky good pointers answers explanation operators data types arrays structures functions recursion preprocessors looping file handling strings switch case if else printf advance linux objective mcq faq online written test prime numbers Armstrong Fibonacci series factorial palindrome code programs examples on c++ tutorials and pdf

Plese Correct the line where "While" starts.........By

while(k<=r)

Using For loop The programa is..... void main() { int i=0,j=1,k,r,f; clrscr(); printf("Enter the number range:"); scanf("%d",&r); printf("\nFIBONACCI SERIES: "); printf("%d %d",i,j); for (k = 2; k <= r; k++) { f = i + j; i = j; j = f; printf(" %d",j); } getch(); }

Your blog keeps getting better and better! Your older articles are not as good as newer ones you have a lot more creativity and originality now keep it up!

void main() { int i,a=0,b=1,c=0,n; clrscr(); printf("\n Enter the lenth of the sequence: "); scanf("%d",&n); if(n==0) { printf("\nPlease enter more than 0 and try again.");

}

else { if(n==1) { printf("\n The fibonacci serice of given length is: "); printf("\n\n %d",a); // getch(); } else if(n==2) { printf("\n The fibonacci serice of given length is: "); printf("\n\n %d\t%d",a,b); } else { printf("\n The fibonacci serice of given length is: "); printf("\n\n %d\t%d",a,b); for(i=3;i<=n;i++) { c=a+b; a=b; b=c; printf("\t%d",c); } } } getch(); }

#include #include #include void main() { int n,i,c; int a=0; int b=1; clrscr(); printf("Enter the number of terms="); scanf("%d",&n); printf("Fibonacci Series"); printf("\n%d\n%d"a,b); for (i=3;i<=n;i++) { c=a=b; a=b; b=c; printf("\n%d",c); } getch(); }

#include main() { int a = 0, b = 1, c; printf("Enter range"); scanf("%d\n",&range); if(range) printf("%d ",a); while(--range) { c = a + b; a = b; b = c; printf("%d ",a); } }

Questions : - Sir please help out on this.? 1.Print the following pattern: A B C D E D C B A A B C D C B A A B C B A A B A A

2. Generate Fibonacci series from 1 to 100 and print it in reverse order.

3. Write an efficient program to reverse characters of each word in a file and write an output file in the same format with all words reversed.

4. Explain the order of complexity in Big-Oh notation, and time taken to process?

5. Work out an algorithm to predict the best times to buy and sell a stock over a 60-day period. Use a suitable data structure so that the “n” th element is the price of the stock on day “n”. ex. 1st element is stock price on day one, 60th element is stock price on day 60.Assume that you start out with 10,000 INR, and value of stock on day 1 is INR 10. Make up any data that you wish for the stock prices. Please provide the input dataset and a working program.

here is a simplest way /* Fibonacci Series c language */ #include #include void main() { int f=0,s=1,ne=0,n,i; clrscr(); printf("Enter any integer value\n"); scanf("%d",&n); printf("%d",f); for (i=0;i<n;i++) { ne=f+s; printf("+%d",ne); s=f; f=ne; } getch(); }

/* Fibonacci Series c language */ #include #include void main() { int n1=0,n2=1,n3=0,n,i; clrscr(); printf("Enter any integer value\n"); scanf("%d",&n); for (i=0;i<n;i++) { n3=n1+n2; printf("+%d",n3); n1=n2; n2=n3; } getch(); }

Sam is a 6th grader, who's got an assignment to check it a number belongs to the Fibonacci series or not. But apparently his friends have called him out to play a game of Cricket. If Sam writes down the series and verifies it all, if would take too long and would probably miss his match. Can you help him solve his problem through a program ?

Input The first line of the input would contain the number of test cases T. Followed by T list of numbers.

Output For a particular test case T, if the number is present in the Fibonacci series, print Y followed by the position of the number in the Fibonacci series. Else print N followed by NOT PRESENT

(Since 1 is present twice in the series, print both the occurrences)

Write a recursive function fast_fib to compute a pair of Fibonacci numbers, F( n + 1) and F( n ). Function fast_fib should make only one recursive call. Algorithm if n is 1 The pair to send back is 1, 1. else Use fast_fib to compute F( n ) and F( n − 1). The pair to send back is [F( n ) + F( n − 1)], F( n ).

## 47 comments:

Plese Correct the line where "While" starts.........By

while(k<=r)

Using For loop The programa is.....

void main()

{

int i=0,j=1,k,r,f;

clrscr();

printf("Enter the number range:");

scanf("%d",&r);

printf("\nFIBONACCI SERIES: ");

printf("%d %d",i,j);

for (k = 2; k <= r; k++)

{

f = i + j;

i = j;

j = f;

printf(" %d",j);

}

getch();

}

"Thanks everybody for the program"

Your blog keeps getting better and better! Your older articles are not as good as newer ones you have a lot more creativity and originality now keep it up!

Thanks you very much

void main()

{

int i,a=0,b=1,c=0,n;

clrscr();

printf("\n Enter the lenth of the sequence: ");

scanf("%d",&n);

if(n==0)

{

printf("\nPlease enter more than 0 and try again.");

}

else

{

if(n==1)

{

printf("\n The fibonacci serice of given length is: ");

printf("\n\n %d",a);

// getch();

}

else if(n==2)

{

printf("\n The fibonacci serice of given length is: ");

printf("\n\n %d\t%d",a,b);

}

else

{

printf("\n The fibonacci serice of given length is: ");

printf("\n\n %d\t%d",a,b);

for(i=3;i<=n;i++)

{

c=a+b;

a=b;

b=c;

printf("\t%d",c);

}

}

}

getch();

}

#include

#include

#include

void main()

{

int n,i,c;

int a=0;

int b=1;

clrscr();

printf("Enter the number of terms=");

scanf("%d",&n);

printf("Fibonacci Series");

printf("\n%d\n%d"a,b);

for (i=3;i<=n;i++)

{

c=a=b;

a=b;

b=c;

printf("\n%d",c);

}

getch();

}

thanks a lot this is great

write a c program to implement the single shorted path problem.

thank you.

Thank u very much for Fibonacci series post.

Thank u very much for Fibonacci series post.but i also need wap Fibonacci series using iterative function

and cosine series

Thanks its helped me.

#include

#include

void main()

{

int i=0,j=1,k,n,count=1;

printf("No. of elements");

scanf("%d",&n);

while(count<=n)

{

printf("%d\t",i);

k=i;

i=i+j;

j=k;

count++;

}

getch();

}

REPLY

what will b the output

char * p="Hello";

?=(*p)*;

A simple way to print fibonacci numbers.

#include

main()

{

int a = 0, b = 1, c;

printf("Enter range");

scanf("%d\n",&range);

if(range)

printf("%d ",a);

while(--range)

{

c = a + b;

a = b;

b = c;

printf("%d ",a);

}

}

#include

#include

void main()

{

clrscr();

int a=0,b=1,c=0,n;

cout<<"Enter the number of terms you wanna see: ";

cin>>n;

cout<<a<<" "<<b<<" ";

for(int i=1;i<=n-2;i++)

{

c=a+b;

a=b;

b=c;

cout<<c<<" ";

}

getch();

}

can you please solve this??

Write a program to calculate the sum of former 40 numbers of series 2/1, 3/2, 5/3, 8/5, 13/8, 21/13,……

How to write a program that will display the sum of the given range.

Sample output: Enter number of range to be added: 5

The sum of given range is: 15

Everything is very open with a clear description of the issues. Many thanks for sharing!

Greetings from Torrent

Questions : - Sir please help out on this.?

1.Print the following pattern:

A B C D E D C B A

A B C D C B A

A B C B A

A B A

A

2. Generate Fibonacci series from 1 to 100 and print it in reverse order.

3. Write an efficient program to reverse characters of each word in a file and write an output file in the same format with all words reversed.

4. Explain the order of complexity in Big-Oh notation, and time taken to process?

5. Work out an algorithm to predict the best times to buy and sell a stock over a 60-day period. Use a suitable data structure so that the “n” th element is the price of the stock on day “n”.

ex. 1st element is stock price on day one, 60th element is stock price on day 60.Assume that you start out with 10,000 INR, and value of stock on day 1 is INR 10. Make up any data that you wish for the stock prices. Please provide the input dataset and a working program.

here is a simplest way

/* Fibonacci Series c language */

#include

#include

void main()

{

int f=0,s=1,ne=0,n,i;

clrscr();

printf("Enter any integer value\n");

scanf("%d",&n);

printf("%d",f);

for (i=0;i<n;i++)

{

ne=f+s;

printf("+%d",ne);

s=f;

f=ne;

}

getch();

}

Fibonacci series

=============

#include

void main()

{

int num,i=0,j=1,k,n;

printf("Enter the number of elements: \n");

scanf("%d",&num);

i=-1;

for(n=0;n<num;n++)

{

k=i+j;

printf("%d ",k);

i=j;

j=k;

}

}

Ans 2:

#include

void main()

{

int num=100,i=0,j=1,k=0,n=0;

i=-1;

k=i+j;

//FINDING LAST ELEMENT

while(1)

{

k=i+j;

if(k>num)

break;

i=j;

j=k;

}

//PRINTING OUTPUT

while(j>=1)

{

k=j-i;

printf("%d ",j);

j=i;

i=k;

}

//ADDING LAST 0

printf("0\n");

}

idea ok. but not working properly for range=0;

i corrected it.

#include

#include

main()

{

int a = 0, b = 1, c=0, range=0;

clrscr();

printf("Enter range");

scanf("%d",&range);

printf("range %d", range);

getch();

if(range)

while(--range)

{

c = a + b;

a = b;

b = c;

printf("\n%d ",a);

}

else

printf("%d",a);

getch();

return (0);

}

write a program to find a. surface area (A=apr2)

b. volume (v=4/3 p3)

Check out fibonacci series program in c for interviews

Great post... but the fab numbers start at 1 not 0. SHould be a quick fix :)

/* Fibonacci Series c language */

#include

#include

void main()

{

int n1=0,n2=1,n3=0,n,i;

clrscr();

printf("Enter any integer value\n");

scanf("%d",&n);

for (i=0;i<n;i++)

{

n3=n1+n2;

printf("+%d",n3);

n1=n2;

n2=n3;

}

getch();

}

can anyone solve this

Sam is a 6th grader, who's got an assignment to check it a number belongs to the Fibonacci series or not. But apparently his friends have called him out to play a game of Cricket. If Sam writes down the series and verifies it all, if would take too long and would probably miss his match. Can you help him solve his problem through a program ?

Input The first line of the input would contain the number of test cases T. Followed by T list of numbers.

Output For a particular test case T, if the number is present in the Fibonacci series, print Y followed by the position of the number in the Fibonacci series. Else print N followed by NOT PRESENT

(Since 1 is present twice in the series, print both the occurrences)

sample Input (Plaintext Link)

5

1

8

4

7

21

Sample Output (Plaintext Link)

Y 2 3

Y 7

N NOT PRESENT

N NOT PRESENT

Y 9

sir pls tell me c programme for n even numbers using break and continue

Write a program containing a recursive function that computes and displays the nth Fibonacci number, given the value for n.

please send me this program

#include

int main(){

int k,r;

int i=0,j=1,f;

printf("Enter the number range:");

scanf("%d",&r);

printf("FIBONACCI SERIES: ");

printf("%d %d",i,j);

for(k=2;k<r;k++){

f=i+j;

i=j;

j=f;

printf(" %d",f);

}

return 0;

}

Can anyone help me?

Write a recursive function fast_fib to compute a pair of Fibonacci numbers,

F( n + 1) and F( n ). Function fast_fib should make only one recursive call.

Algorithm

if n is 1

The pair to send back is 1, 1.

else

Use fast_fib to compute F( n ) and F( n − 1).

The pair to send back is [F( n ) + F( n − 1)], F( n ).

thanks for your answers

After many search i got the correct one which i want. Thank u

Thank you

#include

int main(void)

{

int n,i;

scanf("%d",&n);

int a[n];

a[0]=0;

a[1]=1;

for(i=0;i=2)

{

a[i]=a[i-2]+a[i-1];

printf(" %d",a[i]);

}

else

printf(" %d",a[i]);

}

return 0;

}

Please help on this:

Using a recursive function write a C66 program to display the numbers from 10 to 20

please help me with this: Assuming a is 14 and b is 25 show what is printed by writeln(a,'+',b,'=',a+b);

nice one

can any one teach me c programming language

Fibonacci using pointers...can anyone help me now

anyone please

print 1 -2 3 -4 5 -6...n using loop

please comment urgent

Thank you writer to give us such fantastic things. :) Your presentation is good.

clipping Path

Post a Comment