GeekInterview.com
Series: Subject: Topic:

C Interview Questions

Showing Questions 1 - 5 of 5 Questions
Sort by: 
 | 

Write a program to implement the fibonacci series

Asked By: Interview Candidate | Asked On: Jun 3rd, 2005

Star Read Best Answer

Editorial / Best Answer

Answered by: baseersd

View all answers by baseersd

Member Since Jun-2007 | Answered On : Jul 27th, 2007

Code
  1.  
  2. #include
  3. int main()
  4. {
  5. unsigned int i = 0, j = 0, sum = 1, num;
  6. printf("nEnter the limit for the series ");
  7. scanf("%d", &num);
  8. while (sum < num) {
  9. printf("%d ", sum);
  10. i = j;
  11. j = sum;
  12. sum = i + j;
  13. }
  14. getch();
  15. }
  16.  

Answered by: n.m.sudesh kumar on: Mar 20th, 2013

Code
  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. int pre=0,next=1,sum=0,n;
  6. clrscr();
  7. printf("enter the value of n:");
  8. scanf("%d",&n);
  9. while(pre<=n)
  10. {
  11. printf("the fibonacci series; %d
  12. ",pre);
  13. sum=pre+next;
  14. pre=next;
  15. next=sum;
  16. }
  17. getch();
  18. }

Answered by: madhusudan dadhich on: Jul 24th, 2012

limit:5
01123

Sum of two numbers without using arithmetic operators

Asked By: meda_reddy | Asked On: Jul 15th, 2008

Ex:int a=10;int b=10;int sum=a+b;without using "+" operator calculate sum

Star Read Best Answer

Editorial / Best Answer

Answered by: jintojos

View all answers by jintojos

Member Since May-2008 | Answered On : Jul 17th, 2008

void main()
 {
          int a=10,b=20;
          while(b--) a++;
           printf("Sum is :%d",a);  
 }

Answered by: And on: Aug 28th, 2012

For two positive numbers:

int main(){
int a = 10;
int b = 10;

printf("%d",a ^ b | ((a & b)<< 1));
return 0;
}

Answered by: mahamad on: Jun 14th, 2012

Code
  1. #include<stdio.h>
  2. #include<conio.h>
  3. main()
  4. {
  5.     int a=20,b=10,c;
  6.     clrscr();
  7.     c=a-~b-1;             //it will change the sign of operator truly magic
  8.     printf("sum is %d",c);
  9.     getch();
  10.     return 0;
  11. }

Sequence of function execution

Asked By: pn_5449 | Asked On: Sep 12th, 2009

Printf("%d%d",f1(),f2());what is the sequence of function execution of the above statement. 1. Printf, f1(), f2()2. Printf, f2(), f1()3. F1(), f2(), printf4. F2(), f1(), printf.

Star Read Best Answer

Editorial / Best Answer

Answered by: mohinuddinkhan

View all answers by mohinuddinkhan

Member Since Oct-2009 | Answered On : Oct 30th, 2009

Let's understand this by going through the following code

#include<stdio.h>
int f1();
int f2();

void main()
 {
 printf("%dt%d",f1(),f2());
}

int f1()
{
 printf("f1() enteredn");
 return 4;
}

int f2()
{
 printf("f2() enteredn");
 return 5;
}

O/P-

f2() entered
f1() entered
4        5

we can conclude f2() is 1st executed
then f1() and in the end printf().hence we can say the precedence of execution of functions are from right to left.

Answered by: geek Jack on: Aug 2nd, 2010

printf();
then f2()
then f1()
then again printf()  to print the value in f1 f2 
these are arguments to printf function.

Answered by: omkar.lenka on: Jul 29th, 2010

3)f1(),f2(),printf

What is a const pointer?

Asked By: Interview Candidate | Asked On: Mar 6th, 2005

Star Read Best Answer

Editorial / Best Answer

Answered by: Prasad

Answered On : Apr 27th, 2007

Constant pointer is NOT pointer to constant. Constant pointer means the pointer is constant. For eg:
Constant Pointer
int * const ptr2 indicates that  ptr2 is a pointer which is constant. This means that ptr2 cannot be made to point to another integer. However the integer pointed by ptr2 can be changed.



Where as a Pointer to constant is
const int * ptr1 indicates that ptr1 is a pointer that points to a constant integer. The integer is constant and cannot be changed. However, the pointer ptr1 can be made to point to some other integer.

Answered by: Jegan Chakkravarthy on: Jan 7th, 2011

An ordinary pointer variable preceeded with the "const" modifier. This prevents the value initialised from getting changed.

Answered by: anandkumarjha on: Aug 28th, 2010

Absolutely there is the vast difference between constant pointer and the pointer to a constant.it will be more clear with the examples of both the types.CONSTANT POINTER:-int const *a...this means the...

C if condition puzzle

Asked By: ranjan4unitt | Asked On: May 30th, 2008

What's the "condition" so that the following codesnippet prints both helloworld !If "condition"printf ("hello");elseprintf("world");

Star Read Best Answer

Editorial / Best Answer

Answered by: kiranb_rvce

View all answers by kiranb_rvce

Member Since Jun-2008 | Answered On : Jun 6th, 2008

if ( ! ( printf("Hello ") ) )
printf("Hello");
else
printf("World");

Answered by: fazil.vp on: Apr 24th, 2009

/* Solution 1: */int main(int argc, char* argv[]){ if( argc == 2 || main( 2, NULL ) ) { printf("Hello "); } else { printf("Worldn"); } return 0;}/* Solution 2 (Only for Unix an...

Answered by: dutta_sudipta on: Sep 18th, 2008

Is it like this?

void main()
{
 int a=2;
 while(a--)
 if(a)
  printf("Hello ");
 else
  printf("World!");
}

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.