answersLogoWhite

0

Purpose of printf

Updated: 8/10/2023
User Avatar

Wiki User

11y ago

Best Answer

print means print, f means formatting

or

printf is a output statement function in the C run-time library

example:

printf ("the value of A is %d\n", A);

User Avatar

Wiki User

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

Wiki User

12y ago

by the the printf() function you can show your text/ any decraled variable on the screen it is defined in STDIO.h header file Example of printf is

#include<stdio.h>

void main()

{

printf("hi.. how r u??");

}

(hi how r u??) will be shown on screen

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

"printf" stands for "print formatted", and its purpose is to output a list of variables given a format string. This format string can specify padding and alignment of strings, the number of digits before and after decimal places in floating point numbers, and so on, thus allowing the programmer to output data in a precise format.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

printf statements stands for the output of the program

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Purpose of printf
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What purpose do braces serve in C programming?

grouping statements. eg: if (i==2) printf ("i=="); printf ("2"); and if (i==2) { printf ("i=="); printf ("2"); } do different things, if i&lt;&gt;2


C programming diamond shape for loops Problem and output sample is in the picture?

#include&lt;stdio.h&gt; main() { int i; for(i=1;i&lt;=1;i++) { printf("*",i); } printf("\n"); for(i=1;i&lt;=3;i++) { printf("*",i); } printf("\n"); for(i=1;i&lt;=5;i++) { printf("*",i); } printf("\n"); for(i=1;i&lt;=3;i++) { printf("*",i); } printf("\n"); for(i=1;i&lt;=1;i++) { printf("*",i); } }


Where the printf statements are stored in memory?

Try this: #include &lt;stdio.h&gt; int main (void) { printf ("printf is at location %p\n", (void *)printf); printf ("main is at location %p\n", (void *)main); return 0; }


How can you print percent d on the screen using printf?

printf("Your text here %d", your_data); or maybe you want to see '%d' as output? Try one of these: printf ("%%d"); printf ("%cd", '%'); printf ("%s", "%d"); fputs ("%d", stdout);


Can you give me an example a program of turbo c that determine a zodiac sign?

#include &lt;stdio.h&gt; int main() { int month,date; printf("Enter the month and date of your birth in the format mm-dd:\n"); scanf("%d-%d",&amp;month,&amp;date); if(month&lt;1month&gt;12date&lt;1date&gt;31) { printf("That is not a valid date.\n"); return 1; } printf("Your zodiac sign is "); switch(month) { case 1: if (date&lt;20) printf("Capricorn\n"); else printf("Aquarius\n"); break; case 2: if (date&lt;19) printf("Aquarius\n"); else printf("Pisces\n"); break; case 3: if (date&lt;21) printf("Pisces\n"); else printf("Aries\n"); break; case 4: if (date&lt;20) printf("Aries\n"); else printf("Taurus\n"); break; case 5: if (date&lt;21) printf("Taurus\n"); else printf("Gemini\n"); break; case 6: if (date&lt;21) printf("Gemini\n"); else printf("Cancer\n"); break; case 7: if (date&lt;23) printf("Cancer\n"); else printf("Leo\n"); break; case 8: if (date&lt;23) printf("Leo\n"); else printf("Virgo\n"); break; case 9: if (date&lt;23) printf("Virgo\n"); else printf("Libra\n"); break; case 10: if (date&lt;23) printf("Libra\n"); else printf("Scorpio\n"); break; case 11: if (date&lt;22) printf("Scorpio\n"); else printf("Sagittarius\n"); break; case 12: if (date&lt;22) printf("Sagittarius\n"); else printf("Capricorn\n"); break; } return 0; }

Related questions

What is a purpose of printf and scanf statements?

we write printf() b/c it printf or show us the value contained in a value on the screen after pressing ctrl+f9.


What purpose do braces serve in C programming?

grouping statements. eg: if (i==2) printf ("i=="); printf ("2"); and if (i==2) { printf ("i=="); printf ("2"); } do different things, if i&lt;&gt;2


Can you use nested printf?

printf ("nested printf returned %d\n", printf ("inner printf\n"));


C programming diamond shape for loops Problem and output sample is in the picture?

#include&lt;stdio.h&gt; main() { int i; for(i=1;i&lt;=1;i++) { printf("*",i); } printf("\n"); for(i=1;i&lt;=3;i++) { printf("*",i); } printf("\n"); for(i=1;i&lt;=5;i++) { printf("*",i); } printf("\n"); for(i=1;i&lt;=3;i++) { printf("*",i); } printf("\n"); for(i=1;i&lt;=1;i++) { printf("*",i); } }


Write a program to find the largest of three numbers and print the output in ascending order?

void main() { int a,b,c; clrscr(); printf("Enter the value of a:"); scanf("%d",&amp;a); printf("\nEnter the value of b:"); scanf("%d",&amp;b); printf("\nEnter the value of c:"); scanf("%d",&amp;c); if(a&gt;b) { if(a&gt;c) { if(b&gt;c) { printf("c is smallest\n"); printf("b is middle\n"); printf("a is largest\n"); } else { printf("b is smallest\n"); printf("c is middle\n"); printf("a is largest\n"); } } else { printf("b is smallest\n"); printf("a is middle\n"); printf("c is largest\n"); } } else if(b&gt;c) { if(a&gt;c) { printf("c is smallest\n"); printf("a is middle\n"); printf("b is largest\n"); } else { printf("a is smallest\n"); printf("c is middle\n"); printf("b is largest\n"); } } else { printf("a is smallest\n"); printf("b is middle\n"); printf("c is largest\n"); } getch(); }


What is printf function?

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


What is printf with examples?

print f() 1.function 2.built in 3.user only use 4.out put purpose


Where the printf statements are stored in memory?

Try this: #include &lt;stdio.h&gt; int main (void) { printf ("printf is at location %p\n", (void *)printf); printf ("main is at location %p\n", (void *)main); return 0; }


How do you write a c program to print words when numbers are given?

void print_num_as_word (unsigned num) { switch (num) { case 0: printf ("zero"); break; case 1: printf ("one"); break; case 2: printf ("two"); break; case 3: printf ("three"); break; case 4: printf ("four"); break; case 5: printf ("five"); break; case 6: printf ("six"); break; case 7: printf ("seven"); break; case 8: printf ("eight"); break; case 9: printf ("nine"); break; } }


What should be given at in if printf hello else world to get the output helloworld that is to make both the statements in ifelse clause to execute what should be given in if clause?

main() { if( !fork() ) printf("Hello"); else printf("World"); } This works fine. if (!printf("hello")) printf("Hello"); else printf(" World\n");


Write a program in c language to print a diamond?

// // THIS IS A MACH SIMPLER SOLUTION: // void Diamond(int n) { for (int i=0;i&lt;=2*n;i++,printf("\n")) for (int j=0;j&lt;=2*n;j++) (abs(i-n)+abs(j-n)&lt;=n ? printf("*") : printf(" ")); } //============================================= #include&lt;stdio.h&gt; main() { int i,j,k,n,a,b,c,x; printf("enter the # of rows of graphical output"); scanf("%d",&amp;n); /* UPPER HALF OF KITE */ for(i=1;i&lt;=n;i++) { printf("\t"); for (k=1;k&lt;=(n-i);k++) { printf(" "); } for(j=0;j&lt;i;j++) { printf("*"); printf(" "); } for(k=1;k&lt;=(n-i-1);k++) { printf(" "); } printf("\n"); } /* LOWER PART OF KITE */ for(i=(n-1);i&gt;0;i--) { printf("\t"); for (k=(n-i);k&gt;0;k--) { printf(" "); } for(j=i;j&gt;0;j--) { printf("*"); printf(" "); } for(k=(n-i-1);k&gt;0;k--) { printf(" "); } printf("\n"); } getch(); }


What is the prototype of printf function?

in stdio.h:extern int printf (const char *fmt, ...);