# Accenture Coding Problem #4 | Next Greater Number Today we are going to discuss some important Accenture Coding Questions and answers that has been asked in previous years for engineering Fresher hiring.

So, If you are also appearing in Accenture, then there are fair chances that you can get same difficulty level of questions in your actual exam.

#### Output: 2354Explanation:The next greater number after 2345 is 2345 using {2,3,4,5}

Solution in C++ :

``````#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

void swap(char *a, char *b)
{
char temp = *a;
*a = *b;
*b = temp;
}

void findNext(char number[], int n)
{
int i, j;
for (i = n-1; i > 0; i--)
if (number[i] > number[i-1])
break;
if (i==0)
{
cout << "Next number is not possible";
return;
}
int x = number[i-1], smallest = i;
for (j = i+1; j < n; j++)
if (number[j] > x && number[j] < number[smallest])
smallest = j;
swap(&number[smallest], &number[i-1]);
sort(number + i, number + n);
cout << number;

return;
}

int main()
{
int n;
cin >> n;
char digits[n];
cin >> digits;
findNext(digits, n);
return 0;
}``````

#### Output:

``````4
2345
2354``````