You are on page 1of 2

//to check for fibbonacci series.

#include<stdio.h>
//#include<conio.h>
int main(){
int a,b,c,n;
printf("Enter a number:");
scanf("%d",&n);
a=0;
b=1;
if (n==0){
printf("The number is a fabonacci number.\n");
}
c=a+b;
while(c<n){
a=b;
b=c;
c=a+b;
}
if (c==n){
printf("The number is a fabonacci number.\n");
}
else{
printf("The number is not a fabonacci number.\n");

}
return 0;

Output:-

PS D:\files of c> gcc ass.c


PS D:\files of c> ./a.exe
Enter a number:12
The number is not a fabonacci number.
PS D:\files of c> gcc ass.c
PS D:\files of c> ./a.exe
Enter a number:55
The number is a fabonacci number.
// To check for prime no.

#include<stdio.h>
int main(){
int i,n,c=0;
printf("Enter a no. to be checked:");
scanf("%d",&n);
for(i=1; i<=n; i++){
if (n%i==0){
c=c+1;
}

}
if(c==2){
printf("No. is prime\n");

}
else{
printf("no is not prime\n");

Output

PS D:\files of c> gcc ass.c


PS D:\files of c> ./a.exe
Enter a no. to be checked:12
no is not prime
PS D:\files of c> gcc ass.c
PS D:\files of c> ./a.exe
Enter a no. to be checked:7
No. is prime
PS D:\files of c> ./a.exe
Enter a no. to be checked:19
No. is prime

You might also like