Saturday, June 13, 2020

concatenate unit digits are equal in c

The program must accept an integer M and a digit N as the input. The program must print the concatenated value of M and N as the output if the unit digit of M is not equal to N. Else the program must print M without it’s unit digit as the output.

Example Input/Output 1:
Input:
981 2

Output:
9812



solution:
int main()
{
int a,b;
scanf("%d %d",&a,&b);
if(abs(a)%10!=abs(b)%10){
    printf("%d%d",a,b);
}
else{
    printf("%d",a/10);
}
}

3 comments:

MFIB Comma Separated Integers

Fill in the blanks with code so that the program must accept three integers separated by a space and print them separated by a comma as the ...