Tuesday, 1 January 2019

Find Palindrome Number[c programming examples with output]

C programming examples with output

Palindrome Number


Program

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c,d;
clrscr();
printf("Enter any number: ");
scanf("%d",&a);
b=a;
c=0;
while(n>0)
{
        d=a%10;
        c=(c*10)+d;
        a=a/10;
}
if(b==c)
          printf("%d is Palindrome Number",b);
else
          printf("%d is not Palindrome Number",b);
getch();
}

Output

Enter any number:135
135 is not Palindrome Number
Enter any number:121
121 is Palindrome NUmber 

Monday, 31 December 2018

Find Armstrong Number[c programming examples with output]

C programming examples with output:

Find Armstrong Number

Program

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c,d;
clrscr();
printf("Enter any number : ");
scanf("%d",&a);
b=a;
c=0;
while(a>0)
{
          d=a%10;
          c=c+(d*d*d);
          a=a/10;
}
if(d==c)
          printf("%d is an Armstrong Number",b);
else
          printf("%d is not an Armstrong Number",b);
getch();
}

Output

Enter any number: 153
153 is an Armstrong Number
Enter any number 167
167 is not an Armstrong Number

Find Average Of Odd Numbers Below A Range[c programming examples with output]

C programming examples with output

Find Average Of Odd Numbers Below A Range
Program

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c,d;
float f;
clrscr();
printf("Enter the range: ");
scanf("%d",&b);
a=1;c=0;d=0;
while(a<=b)
{
            if(a%2!=0)
      {
d=d+a;
c++;
}
           a++;
}
f=d/c;
printf("\nThe average of odd numbers below %d: %f",b,f);
getch();
}


Output
Enter the range:20
The average of odd numbers below 20: 10.000000


Check others programming by click here:

Find perfect number or not[c programming examples with output]

C programming examples with output

Find perfect number or not
Program

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

Output
Enter any number: 6
6 is a Perfect number
Enter any number:33
33 is not a Perfect number


Check others programming by click here: