Palindrome and armstrong in function C programming
Palindrome in function :
............................................................................................................
#include<stdio.h>
#include<conio.h>
int palen(int);
int main()
{
int n,p;
printf("Enter number to check palindrome:");
scanf("%d",&n);
p=palen(n);
if(p==n)
printf("%d is palen",p);
else
printf("no palindrome");
getch();
}
int palen(int x)
{
int rev=0, r ;
while(x!=0)
{
r=x%10;
x=x/10;
rev=rev*10+r;
}
return(rev);
}
............................................................................................................
OUTPUT:
.....................................................................................................
......................................................................................................
Output:
............................................................................................................
#include<stdio.h>
#include<conio.h>
int palen(int);
int main()
{
int n,p;
printf("Enter number to check palindrome:");
scanf("%d",&n);
p=palen(n);
if(p==n)
printf("%d is palen",p);
else
printf("no palindrome");
getch();
}
int palen(int x)
{
int rev=0, r ;
while(x!=0)
{
r=x%10;
x=x/10;
rev=rev*10+r;
}
return(rev);
}
............................................................................................................
OUTPUT:
Armstrong in function C programming
......................................................................................................
#include<stdio.h>
#include<conio.h>
#include<math.h>
int arm(int);
int main()
{
int n,p;
printf("Enter number to check Armstrong:");
scanf("%d",&n);
p=arm(n);
if(p==n)
printf("%d is arm",p);
else
printf("no arm");
getch();
}
int arm(int x)
{
int rev=0, r ;
while(x!=0)
{
r=x%10;
x=x/10;
rev=rev+ pow(r,3);
}
return(rev);
}
Output:
......................................................................................................
Other C Programming:
C programming beginner from Hello World
Keywords in C programming
Palindrome and armstrong in function C programming
Nepali Flag in C programming
switch statement using character in C programming
Control Statement in C programming
Control Statements in C programming (if and else)
Program for Stack Using switch( PUSH POP DISPLAY and empty
Examples of while, Do while
Keywords in C programming
Palindrome and armstrong in function C programming
Nepali Flag in C programming
switch statement using character in C programming
Control Statement in C programming
Control Statements in C programming (if and else)
Program for Stack Using switch( PUSH POP DISPLAY and empty
Examples of while, Do while
Thank you soo much !! i need this
ReplyDelete