answersLogoWhite

0


Best Answer

The syntax for printf is:

int printf(const char *format, ...);

Simple usage examples:

1. Print character literal: printf("%c", 'a');

2. Print character variable: printf("%c", my_char);

3. Print string literal: printf("%s", "hello world");

4. Print string variable: printf("%s", my_string);

5. Print integer variable: printf("%d", my_integer);

6. Print floating-point variable: printf("%f", my_float);

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

printf() is used to print a formatted string to the standard output.

It's usage is af follows:

"printf(const char * format, ...)"

where 'format' is a string to be printed to the standard output, optionally containing format tags that will be replaced by the arguments that follow (...).

Example:

...

char *name = "Alice";

printf("Hello there, %s!\n", name);

output:

Hello there, Alice!

'%s' was replaced with the contents of the variable 'name' (Alice).

Please see the documentation for a full list of format tags and usage.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

The printf function formats data in the form of strings, integers, floating-point numbers, characters, and pointers, and sends it to the standard output stream.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Printing formatted data.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is main function of printf in a C program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How you write a c program for making a call in gcc?

int main() { // Call the printf function printf("This is a function call!\n"); return 0; }


How do you write a programme in c?

Basic Program in "C" #include <stdio.h> /*This is the standard input/output library function*/ main(void) /*All C programs must have the function main*/ { char ch; printf("This is a C Program."); /* Every line of code in C must end with a semi colon*/ printf("Welcome to C!");/*the printf outputs the line of text to the screen*/ scanf("%c%c", &ch, &ch); /* This is a trick way to pause the computer so you can read the information on the screen*/ return 0; /* Indicates that your program has terminated successfully*/


Write a c program to have followiing as output?

void main() { printf("followiing"); }


Give an example of computer program?

A C program #include <stdio.h> int main() { printf("Hello, world!"); }


What must every c program have?

A main function must be present in every C program.


How do you display semi colon without using semi colon in a c program?

main() { if(printf("%c",59)) }


What is main function used in c?

if you do not used main function in c program when errors are accrued


How can a person write a program without using printf function in C language?

Here is an example:#include int main (void){puts ("Hello, world");return 0;}


What is printf function?

Printf function is used in c language. Printf is used to print something to the standard output. ex: printf ('welcome');


How do you write a c program without using main function?

You cannot create a program with the extension .exe without the function main. You can create a dll which does not even use main. WinApi uses another main function but it's still a main function. Main function is entry point for your program, no entry point no program.Write a progrmme in c with out using a main function. #include #define decode(s,t,u,m,p,e,d)m##s##u##t #define begin decode(a,n,i,m,a,t,e) int begin() { printf("HELLO") }


Exchange to interchange in two var in c program?

#include#includevoid main(){ int a,b,c;printf("\nEnter 1st no.");scanf("%d",&a);printf("\nEnter 2nd no.");scanf("%d",&b);c=a;a=b;b=c;printf("\n1st no.",a);printf("\n2nd no.",b);getch();}


Where do we write main function in a c program?

Into the source program.