How to separate numbers with spaces in C language output?

In C language, you can use a space character to separate numbers. Here is an example code that demonstrates how to output numbers separated by spaces:

#include<stdio.h>

int main() {
    int num1 = 10;
    int num2 = 20;
    int num3 = 30;

    printf("%d %d %d\n", num1, num2, num3);

    return 0;
}

In the code above, the %d format specifier is used to output integer variables, and space characters are inserted between every two numbers. The output of the execution will display 10 20 30, with each number separated by a space.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds