Reframe with Hundredth Digit

The program must accept an integer N and a sum value X (sum of unit digit, tenth digit and hundredth digit of N) as the input. The hundredth digit is removed from N. The program must find the hundredth digit and print N by reframing it as the output.
Boundary Condition(s):
1 <= N <= 10^8
1 <= X <= 27
Input Format:
The first line contains the two integer values N and X separated by a space.
Output Format:
The first line contains the reframed N.
Example Input/Output 1:
Input:
1269 20
Output:
12569
Explanation:
The sum of the last two digits in 1269 is 15. The difference between 20 and 15 is 5 (20-15).
So the hundredth digit is 5. After reframing the N is 12569.
Hence the output is 12569.
 
Example Input/Output 2:
Input:
43217 9
Output:
432117

Solution:-

#include<stdio.h>
#include <stdlib.h>

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    
    int ud=a%10;
    int td=(a/10)%10;
    
    
    int dig=b-(ud+td),sum=0;
    
    int x=a/100;
    
    int num=x*1000+dig*100+td*10+ud;
    
    printf("%d",num);
    
    


}

Comments

Popular posts from this blog

Two Matrix Spiral Print

Alphabets Positions Reversed

Odd Factors - (Error Identification) skillrack program id - 7306