How can the C language output “%”?

In C language, to print the percentage sign (%), you can use the escape sequence “%%”. When you use double percentage signs (%%), the compiler will interpret it as a single percentage sign and output it.

The following example program demonstrates how to output a percent sign (%) in the C language.

#include <stdio.h>

int main() {

    printf("输出一个百分号: %%\n");

    return 0;

}

In the code above, we utilized the `printf()` function to display a percentage sign. By using two percentage signs (%%), we were able to successfully print a percentage sign.

When you run this program, it will display:

输出一个百分号: %
bannerAds