Professional Documents
Culture Documents
Ans.
/*c program to check a number is include in
Fibonacci term or not*/
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c,next,num;
printf("Enter any number: ");
scanf("%d", &num);
if((num==0)||(num==1))
printf("\n%d is a Fibonacci term",num);
else
{
a=0;
b=1;
c=a+b;
while(c<num)
{
a=b;
b=c;
c=a+b;
}
if(c==num)
printf("\n%d is a Fibonacci
term",num);
else
printf("\n%d is not a Fibonacci
term",num);
}
getch();
return 0;
}
/************Output************/
int main()
{
int n, i;
bool isPrime = true;
return 0;
}
Write a C, C++ program to check whether a given number is perfect or not. We have to write a program to check
Perfect Number
A perfect number, is a positive integer that is equal to the sum of its proper divisors.
28 = 1 + 2 + 4 + 7 + 14
#include <iostream>
int main() {
int num, sum = 0;
cout << " Enter a number to check whether it's a perfect or not \n";
if (num % i == 0) {
sum = sum + i;
if ( sum == num) {
} else {
return 0;
}
isFibo.cpp
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int t;
cin >> t;
while( t-- )
{
long long n;
cin >> n;
double root = sqrt(5.0*n*n+4.0);
long long iRoot = root;
if( root == iRoot )
{
cout << "IsFibo" << endl;
}
else
{
root = sqrt(5.0*n*n-4.0);
iRoot = root;
if( root == iRoot )
{
cout << "IsFibo" << endl;
}
else
{
int main()
{
int num,factorial=1;
cin>>num;
for(int a=1;a<=num;a++)
factorial=factorial*a;
return 0;
}
Image View Of Program