printf function
When the c program needs to communicate with the user, We should use printf function.
The communication can be,
Greeting the user
"welcome to c program"
Asking input from the user
"Enter your username/password" etc.
Note
printf function is defined in stdio.h header file.
So if we want to use the printf function in our c program, we should include stdio.h header file.
Syntax of printf
printf("");
It will print characters to the screen which is given inside the double quotes "" .
And it should end up with a semicolon ;.
Example
printf("Hello World"); printf("Enter two numbers"); printf("Bye");
Sample Program
Example
#include<stdio.h> //header section int main() //main section { printf("Welcome to the C Programming"); return 0; }
Correct the below program
The below program has some syntax errors.
Correct the program by yourself and see the output.
Useful Resources
http://man7.org/linux/man-pages/man3/printf.3.htmlhttps://en.wikipedia.org/wiki/Printf_format_string