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);
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
"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.
printf statements stands for the output of the program
grouping statements. eg: if (i==2) printf ("i=="); printf ("2"); and if (i==2) { printf ("i=="); printf ("2"); } do different things, if i<>2
#include<stdio.h> main() { int i; for(i=1;i<=1;i++) { printf("*",i); } printf("\n"); for(i=1;i<=3;i++) { printf("*",i); } printf("\n"); for(i=1;i<=5;i++) { printf("*",i); } printf("\n"); for(i=1;i<=3;i++) { printf("*",i); } printf("\n"); for(i=1;i<=1;i++) { printf("*",i); } }
Try this: #include <stdio.h> int main (void) { printf ("printf is at location %p\n", (void *)printf); printf ("main is at location %p\n", (void *)main); return 0; }
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);
#include <stdio.h> int main() { int month,date; printf("Enter the month and date of your birth in the format mm-dd:\n"); scanf("%d-%d",&month,&date); if(month<1month>12date<1date>31) { printf("That is not a valid date.\n"); return 1; } printf("Your zodiac sign is "); switch(month) { case 1: if (date<20) printf("Capricorn\n"); else printf("Aquarius\n"); break; case 2: if (date<19) printf("Aquarius\n"); else printf("Pisces\n"); break; case 3: if (date<21) printf("Pisces\n"); else printf("Aries\n"); break; case 4: if (date<20) printf("Aries\n"); else printf("Taurus\n"); break; case 5: if (date<21) printf("Taurus\n"); else printf("Gemini\n"); break; case 6: if (date<21) printf("Gemini\n"); else printf("Cancer\n"); break; case 7: if (date<23) printf("Cancer\n"); else printf("Leo\n"); break; case 8: if (date<23) printf("Leo\n"); else printf("Virgo\n"); break; case 9: if (date<23) printf("Virgo\n"); else printf("Libra\n"); break; case 10: if (date<23) printf("Libra\n"); else printf("Scorpio\n"); break; case 11: if (date<22) printf("Scorpio\n"); else printf("Sagittarius\n"); break; case 12: if (date<22) printf("Sagittarius\n"); else printf("Capricorn\n"); break; } return 0; }
we write printf() b/c it printf or show us the value contained in a value on the screen after pressing ctrl+f9.
grouping statements. eg: if (i==2) printf ("i=="); printf ("2"); and if (i==2) { printf ("i=="); printf ("2"); } do different things, if i<>2
printf ("nested printf returned %d\n", printf ("inner printf\n"));
#include<stdio.h> main() { int i; for(i=1;i<=1;i++) { printf("*",i); } printf("\n"); for(i=1;i<=3;i++) { printf("*",i); } printf("\n"); for(i=1;i<=5;i++) { printf("*",i); } printf("\n"); for(i=1;i<=3;i++) { printf("*",i); } printf("\n"); for(i=1;i<=1;i++) { printf("*",i); } }
void main() { int a,b,c; clrscr(); printf("Enter the value of a:"); scanf("%d",&a); printf("\nEnter the value of b:"); scanf("%d",&b); printf("\nEnter the value of c:"); scanf("%d",&c); if(a>b) { if(a>c) { if(b>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>c) { if(a>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(); }
Printf function is used in c language. Printf is used to print something to the standard output. ex: printf ('welcome');
print f() 1.function 2.built in 3.user only use 4.out put purpose
Try this: #include <stdio.h> int main (void) { printf ("printf is at location %p\n", (void *)printf); printf ("main is at location %p\n", (void *)main); return 0; }
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; } }
main() { if( !fork() ) printf("Hello"); else printf("World"); } This works fine. if (!printf("hello")) printf("Hello"); else printf(" World\n");
// // THIS IS A MACH SIMPLER SOLUTION: // void Diamond(int n) { for (int i=0;i<=2*n;i++,printf("\n")) for (int j=0;j<=2*n;j++) (abs(i-n)+abs(j-n)<=n ? printf("*") : printf(" ")); } //============================================= #include<stdio.h> main() { int i,j,k,n,a,b,c,x; printf("enter the # of rows of graphical output"); scanf("%d",&n); /* UPPER HALF OF KITE */ for(i=1;i<=n;i++) { printf("\t"); for (k=1;k<=(n-i);k++) { printf(" "); } for(j=0;j<i;j++) { printf("*"); printf(" "); } for(k=1;k<=(n-i-1);k++) { printf(" "); } printf("\n"); } /* LOWER PART OF KITE */ for(i=(n-1);i>0;i--) { printf("\t"); for (k=(n-i);k>0;k--) { printf(" "); } for(j=i;j>0;j--) { printf("*"); printf(" "); } for(k=(n-i-1);k>0;k--) { printf(" "); } printf("\n"); } getch(); }
in stdio.h:extern int printf (const char *fmt, ...);