C - getting multiple int input in one scan while ignoring whitespaces

Viewed 40

The first line will contain a message prompt to input the number when I'm in whole. The second line will contain a message prompt to input the number when I'm in parts. The last line contains "Yes" if I'm the same when I'm whole and when I'm in parts and "No" otherwise.

Enter·the·number·(whole):·41598

Enter·the·number·(parts):·4·1·5·9·8

Yes

I've been stuck with this practice problem for quite a while now, and I wanna know what else can I do, looping with a string is one of my ideas but I can't get it to work, and I think there would be an easier way to solve this.

#include <stdio.h>

int main()
{
    int whole, parts, totalparts = 0;

    printf("Enter the number (whole): ");
    scanf("%d", &whole);
    printf("Enter the number (parts): ");
    scanf("%d", parts);
    
    if (whole == totalparts)
        printf("Yes");
    else
        printf("No");
    
    return 0;
}
0 Answers
Related