In a C program, the output of text is typically displayed on the screen using the printf() function, which is part of the Standard Input Output library (stdio.h).
Example of Displaying Output:
Here’s a simple example of how to use printf() to display text on the screen:
#include <stdio.h>
int main() {
printf("Hello, World!\n"); // Displaying text on the screen
return 0;
}
Explanation:
#include <stdio.h>: This line includes the Standard Input Output library, which contains the declaration for theprintf()function.int main(): This is the main function where the execution of the program begins.printf("Hello, World!\n");: This line calls theprintf()function to print the string "Hello, World!" to the screen. The\nis a newline character that moves the cursor to the next line after printing.return 0;: This indicates that the program has executed successfully.
When you run this program, the output will be displayed on the terminal as:
Hello, World!
This is how text output is typically displayed in a C program.
