how to use printf with c++
#include <iostream>
int main() {
int number = 10;
printf("The number is: %d\n", number);
return 0;
}
- Include the necessary header file
<iostream>
for input/output operations. - Define the
main
function as the entry point of the program. - Declare an integer variable
number
and initialize it to 10. - Use the
printf
function to print the value ofnumber
using the%d
format specifier for integers. - Return 0 to indicate successful program execution.