Program to Check Whether Number is Perfect Or Not

Program to Check Whether Number is Perfect Or Not

Program to Check Whether Given Number is Perfect Or Not ?
#include<stdio.h>
int main()
{
int n,i=1,sum=0;
  printf("nEnter a number: ");
  scanf("%d",&n);
  while(i<n){
      if(n%i==0)
           sum=sum+i;
          i++;
  }
  if(sum==n)
      printf("n%d is a Perfect Number",i);
  else
      printf("n%d is Non Perfect Number",i);
  return 0;
}
C Progranm to Check for Armstrong Number

C Progranm to Check for Armstrong Number

Armstrong Number : When Sum of Cubes of Digits Of Number Equal to Same Given Number then the number is called as Armstrong Number.
#include<stdio.h>
int main()
{
int num,temp,sum=0,rem;

printf("nEnter Number For Checking Armstrong : ");
scanf("%d",&num);

temp = num;

 while (num != 0)
 {
  rem = num % 10;
  sum = sum + (rem*rem*rem);
  num = num / 10;
 }

if(temp == sum)
    printf("n%d is Amstrong Number",temp);
else
    printf("n%d is Amstrong Number",temp);
return(0);
}

Output :
Enter Number For Checking Armstrong : 153
153 is Amstrong Number
Explanation :
153 = [1*1*1] + [5*5*5] + [3*3*3]
    = 1 + 125 + 27
    = 153
Check Whether Number is Prime or not

Check Whether Number is Prime or not

#include<stdio.h>
int main()
{
    int num,i,count=0;
    printf("nEnter a number:");
    scanf("%d",&num);
    for(i=2;i<=num/2;i++){
        if(num%i==0){
         count++;
            break;
        }
    }
   if(count==0)
        printf("%d is a prime number",num);
   else
      printf("%d is not a prime number",num);
   return 0;
}
Check Whether Given Number is Palindrome or Not ????

Check Whether Given Number is Palindrome or Not ????

Check Whether Given Number is Palindrome or Not ????
#include<stdio.h>
#include<string.h>
int main()
{
int num,i,count=0;
char str1[10],str2[10];

printf("nEnter a number:");
scanf("%d",&num);

sprintf(str1,"%d",num); // Convert Number to String

strcpy(str2,str1); // Copy String into Other
strrev(str2); // Reverse 2nd Number

count = strcmp(str1,str2);

if(count==0)
     printf("%d is a prime number",num);
else
     printf("%d is not a prime number",num);
return 0;
}
C Program To Print First 10 Natural Numbers

C Program To Print First 10 Natural Numbers

Using For Loop
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1;
clrscr();
for(i=1;i<=10;i++)
  printf("%d",i);
getch();
}

Using While Loop
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1;
clrscr();
while(i<=10)
  {
  printf("%d",i);
  i++;
  }
getch();
}

Using Do-While Loop
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1;
clrscr();
do{
  printf("%d",i);
  i++;
  }while(i<=10);
getch();
}
C Program to generate the Fibonacci Series starting from any two numbers

C Program to generate the Fibonacci Series starting from any two numbers

#include<stdio.h>
#include<conio.h>

int main()
{
int first,second,sum,num,counter=0;
clrscr();

printf("Enter the term : ");
scanf("%d",&num);

printf("nEnter First Number : ");
scanf("%d",&first);

printf("nEnter Second Number : ");
scanf("%d",&second);

printf("nFibonacci Series : %d  %d  ",first,second);

while(counter< num)
    {
    sum=first+second;
    printf("%d  ",sum);
    first=second;
    second=sum;
    counter++;
    }
getch();
}

Output :
Enter the term : 5
Enter First Number : 1

Enter Second Number : 3

Fibonacci Series : 1 3 4 7 11 18 29