Computer Science, asked by jessikrish2809, 9 months ago

Write a 'C' program .Input a and b .Find the smallest number greater than b by inter changing the digits of a and if not possible return -1

Answers

Answered by XxMaverickxX
6

Answer:

/* Write a C' program .Input a and b .Find the smallest number greater than b by inter changing the digits of a and if not possible return -1 */

#include<stdio.h>

main()

{

int a, b,rev=0,d,return;

do

{

printf("Enter two numbers a and b \n");

scanf("%d %d", &a, &b)

}while(b<a);

while(a!=0)

{

d=a%10;

rev=(rev*10)+d;

a=a/10;

}

if(rev>b)

{

printf("%d is greater than %d \n", rev,b);

}

else if (rev==b)

{

print{"Both are equal \n");

}

else

{

return= -1;

printf("%d",return)

}

}

Answered by qwtiger
0

Answer:

#include<stdio.h>

main()

{ int a, b,rev=0,d,return;

do{

printf("Enter two numbers a and b \n");

scanf("%d %d", &a, &b)

}while(b<a);

while(a!=0)

{ d=a%10;

rev=(rev*10)+d;

a=a/10;

}

if(rev>b)

{  printf("%d is greater than %d \n", rev,b);

}

else if (rev==b)

{  print{"Both are equal \n");

}

else

{ return= -1;

printf("%d",return)

}

}

Similar questions