sprintf and atoi

Lab C Intermediate 20 points

Read two numbers as words. Convert them with atoi, then build the text A+B=SUM with sprintf and print it and its length.

Input

Two integers.

Output

Two lines.

Example

Input

12 30

Output

12+30=42
8
Sample input available Sample output available
Editor
C

Hints

atoi converts text to int; sprintf prints into a char array.

Solution explanation

sprintf works like printf but writes into a buffer.

Show solution
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
    char a[20], b[20], out[60];
    scanf("%s %s", a, b);
    int x = atoi(a), y = atoi(b);
    sprintf(out, "%d+%d=%d", x, y, x + y);
    printf("%s\n%d\n", out, (int) strlen(out));
    return 0;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD