#include<stdio.h> #include<conio.h> int main() { int n,r,sum=0,temp; printf("enter the number="); scanf("%d",&n); temp=n; while(n>0) { r=n%10; sum=(sum*10)+r; n=n/10; } if(temp==sum) printf("palindrome number "); else printf("not palindrome"); return 0; } Output:- enter the number=14341 palindrome number enter the number=1341 not palindrome
#include<stdio.h> #include<conio.h> int fact(int); int main() { int x,n; printf(" Enter the Number to Find Factorial :"); scanf("%d",&n); x=fact(n); printf(" Factorial of %d is %d",n,x); return 0; } int fact(int n) { if(n==0) return(1); return(n*fact(n-1)); } Output:- Enter the Number to Find Factorial :3 Factorial of 3 is 6
#include<stdio.h> #include <conio.h> int main() { int a[1000],i,n,min,max; printf("Enter size of the array : "); scanf("%d",&n); printf("Enter elements in array : "); for(i=0; i<n; i++) { scanf("%d",&a[i]); } min=max=a[0]; for(i=1; i<n; i++) { if(min>a[i]) min=a[i]; if(max<a[i]) max=a[i]; } printf("minimum of array is : %d",min); printf("\nmaximum of array is : %d",max); return 0; } Output:- Enter size of the array: 5 Enter elements in array: 1 2 3 4 5 minimum of an array is: 1 maximum of an array is: 5
Comments
Post a Comment