write a function -oriented program that generates the
Fibonacci, the current numbers of n(as input) and display
them (series). In Fibonacci, the current third number is the
sum of the previous number.
Answers were Sorted based on User's Feedback
Answer / karthik
#include<iostream.h>
int main()
{
int a=-1,b=1,c,n;
printf("Enter the length of series");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
c=a+b;
a=b;
b=c;
printf("%d",c);
}
return 0;
}
Is This Answer Correct ? | 11 Yes | 2 No |
Answer / mkk
#include<stdio.h>
void fibo(int x)
{
int f1=0,f2=1,f;
for(i=1;i<num;i++)
{
f=f1+f2;
f1=f2;
f2=f;
printlf(",%d",f2);
}
void main()
{
int num;
clrscr();
printf("enter the number");
scanf("%d",&num);
printf("0,1");
fibo(num);
getch();
}
Is This Answer Correct ? | 4 Yes | 5 No |
Min-Max Write an algorithm that finds both the smallest and largest numbers in a list of n numbers and with complexity T(n) is at most about (1.5)n comparisons.
10 Answers ABC, College School Exams Tests, ITC Infotech, Kyambogo University, Qatar University,
write a program that can LOCATE and INSERT elements in array using c++ programming languages.
write a program using 2 D that searches a number and display the number of items 12 inputs values input 15,20, 13, 30, 38, 40,16, 18, 20 ,18 ,20 enter no. to search : 20
How to swap two ASCII numbers?
Write a program to enter 10 number of integer entries into an array n and then odds up all the odd entries. the program then displays the result. plssss answer assss fast asss u can...
How do I store linked list datas into an array?
Display Pattern: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 …
main(){int a=5,b 10,c=2, d;a=b c;d=++a=(--c)*2; printf("%d%d%d%d,a,b,c,d; return o;}
Write a (n) algorithm that sorts n distinct integers, ranging in size between 1 and kn inclusive, where k is a constant positive integer. (Hint: Use a kn-element array.)
What is the time complexity T(n) of the following program? a) int n, d, i, j; cin >> n; for (d=1; d<=n; d++) for (i=1; i<=d; i++) for (j=1; j<=n; j += n/10) cout << d << " " << i << " " << j << endl; b) void main() { int n, s, t; cin >> n; for (s = 1; s <= n/4; s++) {t = s; while (t >= 1) { cout << s << " " << t << endl; t--; } } } c) void main() { int n, r, s, t; cin >> n; for (r = 2; r <= n; r = r * 2) for (s = 1; s <= n/4; s++) { t = s; while (t >= 1) { cout << s << " " << t << endl; t--; } } }
3 Answers CTS, IBM, Infosys, Qatar University,
Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)
what is virtual constroctor ? give an exam for it?-(parimal dhimmar)