CCCCCCCCCCCCCCCCC

Sunday, 29 December 2019

C program to check prime or composite

#include<stdio.h>
#include<conio.h>
void main()
{
    int n,i;
    printf("enter the number for finding:");
    scanf("%d",&n);
    for(i=2;i<=n;i++)
    {
      if(n%i==0)
      break;
    }
    if(n==i)
        printf("The number is prime number.");
    else
        printf("the number is composite number.");
getch();
}

Tuesday, 24 December 2019

C program to check the given number is palindrome or not.

#include<stdio.h>
void main()
{
    int n, temp, sum=0,d;
    printf("\n enter the number:");
    scanf("%d",&n);
    temp=n;
    while (n!=0)
    {
        d=n%10;
        sum = sum*10+d;
        n = n/10;
    }
    if (temp==sum)
        printf("\n the number is Palindrome.");
    else
        printf("\n the number is not Palindrome.");
    getch();
}

C program to dispay Fibonacci series to nth term.

#include<stdio.h>
#include<conio.h>
void main()
{
    int i, a=0, b=1, c=1,n;
    printf("\n enter the number of terms to be displayed:");
    scanf("%d",&n);
    for (i=0;i<n;i++)
    {
        printf("%d\t",c);
        c=a+b;
        a=b;
        b=c;
    }
    getch();
}