C Programming Code Examples C > Strings Code Examples C Program that Takes Input as 2323 and Gives Output as 2332 C Program that Takes Input as 2323 and Gives Output as 2332 This is a C program to find a greater number of entered number using same digits. This program takes a number as input and finds a greater number of the entered number using same digits. - Take a number as input. - Reverse the number and store it in the array. - Using for loop check if the array[x] is greater than array[x+1]. If it is, then interchange them. - The number in the array after swapping is the required number. #include <stdio.h> #include <math.h> int evaluate(int [], int); int find(int); int main() { int num, result; printf("Enter a number: "); scanf("%d", &num); result = find(num); if (result) { printf("The number greater than %d and made of same digits is %d.\n", num, result); } else { printf("No higher value possible. Either all numbers are same or the digits of the numbers entered are in decreasing order.\n"); } return 0; } int find(int num) { int digit[20]; int x = 0, len = 0, n, temp; n = num; while (n != 0) { digit[x] = n % 10; n = n / 10; x++; } len = x; for (x = 0; x < len - 1; x++) { if (digit[x] > digit[x + 1]) { temp = digit[x]; digit[x] = digit[x + 1]; digit[x + 1] = temp; return (evaluate(digit, len)); } } return 0; } int evaluate(int digit[], int len) { int x, num = 0; for (x = 0; x < len; x++) { num += digit[x] * pow(10, x); } return num; } Take a number as input and store it in the variable num. Use the functions evaluate() and find() to find the number. In the function find() reverse the input number and store it in the array digit[]. Use while loop to do this. Using for loop check if digit[x] is greater than digit[x+1]. If it is, then swap their values and call the function evaluate(). In this function multiply the array elements with the power of 10 and add all the multiplied values to get the required number.