Write a program to check whether the number is prime and also
check if it there i n fibonacci series, then return true
otherwise return false



Write a program to check whether the number is prime and also check if it there i n fibonacci ser..

Answer / surendra

include<stdio.h>
int main(){
int k,r;
long int i=0l,j=1,f;

//Taking maximum numbers form user
printf("Enter the number range:");
scanf("%d",&r);

printf("FIBONACCI SERIES: ");
printf("%ld %ld",i,j); //printing firts two values.

for(k=2;k<r;k++){
f=i+j;
i=j;
j=f;
printf(" %ld",j);
}

return 0;
}

Is This Answer Correct ?    3 Yes 4 No

Post New Answer

More C Code Interview Questions

#include<stdio.h> main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }

1 Answers  


¦void main() ¦{ ¦int i=10,j; ¦ j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-30 but in same question if we write as- ¦void main() ¦{ ¦int i=10; ¦ int j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-33 why output is changed from 30 to 33. Can any body answer...

3 Answers  


void main() { static int i; while(i<=10) (i>2)?i++:i--; printf(ā€œ%dā€, i); }

2 Answers  


main() { int i = 0xff ; printf("\n%d", i<<2); } a. 4 b. 512 c. 1020 d. 1024

2 Answers   HCL,


How can you relate the function with the structure? Explain with an appropriate example.

0 Answers  






char inputString[100] = {0}; To get string input from the keyboard which one of the following is better? 1) gets(inputString) 2) fgets(inputString, sizeof(inputString), fp)

1 Answers  


given integer number,write a program that displays the number as follows: First line :all digits second line : all except the first digit . . . . Last line : the last digit

8 Answers  


main() { unsigned char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

1 Answers  


Give a very good method to count the number of ones in a 32 bit number. (caution: looping through testing each bit is not a solution)

7 Answers   Microsoft,


How do you sort a Linked List (singly connected) in O(n) please mail to pawan.10k@gmail.com if u can find an anser...i m desperate to knw...

6 Answers   Microsoft, MSD, Oracle,


main() { clrscr(); } clrscr();

2 Answers  


How can i find first 5 natural Numbers without using any loop in c language????????

2 Answers   Microsoft,


Categories