#include <stdio.h>
#include <conio.h>
void main()
{
int num,rev=0,m,r;
clrscr();
printf("enter any number");
scanf("%d",&num);
m=num;
while(num>0)
{
r=num%10;
rev=rev*10+r;
num=num/10;
}
if(rev==m)
printf("given number is palindrome");
else
printf("given number is not palindrome");
getch();
}
this is the answer.
Note: The following is pseudo-code (I tried to make it as close to code as possible)
Because there are so many programming languages it would not be good to answer
this question with one language. So, you should be able to take this pseudo-code and
finish it in your language. This is very close to C.
integer palindrome(char[] string)
{
if (length(string) 0) /* we are looking at the last 2 characters
return 1 (true)
palindrome(newstring[]); /* Call palindrome again with two less characters */
}
return 0 (false)
}
Write a program using recursion which should take two values and display 1st value raised to the power of second value.
sdfdg
Sure, recursion can always be substituted with using a stack.
Palindrome number is a number like 121 which remains the same when its digits are reversed. To find this number in a simple java program, just follow the below way. sum = 0; while(n>0) { r=n % 10; sum=concat(r); n=n / 10; } print r;
Yes. It is possible to provide a solution to the diamond-square algorithm using Java and recursion.
123
Write a program using recursion which should take two values and display 1st value raised to the power of second value.
sdfdg
Sure, recursion can always be substituted with using a stack.
pata nhe
Ans: Merits of recursion are: Mathematical functions, such as Fibonacci series generation can be easily implemented using recursion as compared to iteration technique. Demerits of recursion are: Many programming languages do not support recursion; hence, recursive mathematical function is implemented using iterative methods. Even though mathematical functions can be easily implemented using recursion, it is always at the cost of execution time and memory space. The recursive programs take considerably more storage and take more time during processing.
Palindrome number is a number like 121 which remains the same when its digits are reversed. To find this number in a simple java program, just follow the below way. sum = 0; while(n>0) { r=n % 10; sum=concat(r); n=n / 10; } print r;
int sum (int n) { if (n<=1) return n; else return n + sum (n-1); }
int sum(n) { if (n==0) return 0; else return n+sum(n-1); }
Yes. It is possible to provide a solution to the diamond-square algorithm using Java and recursion.
recu
Demerits of recursion are: Many programming languages do not support recursion; hence, recursive mathematical function is implemented using iterative methods. Even though mathematical functions can be easily implemented using recursion, it is always at the cost of execution time and memory space. The recursive programs take considerably more storage and take more time during processing.