printf() is a build-in function under the header file 'stdio.h' in a C Programming language. In c++,the same function is accomplished by 'cout' . It is used to display strings enclosed between double quotes. Its syntax is
printf("...string/sentences/characters....");
After execution,all the characters between the double quotes will be displayed on the output screen.
printf ("nested printf returned %d\n", printf ("inner printf\n"));
No, it is a function. But printf does return a value: the number of characters it has written.
You can use fputs() instead of printf().
Printf prints something to the standard output stream, and scanf inputs something from the standard input stream.
#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); } }
Everywhere in the code when there is no 'break', the running will continue with the next instruction. Example: for (i=0; i<3; ++i) { printf ("i=%d: ", i); switch (i) { case 2: printf ("two "); case 1: printf ("one "); case 0: printf ("zero "); } printf ("\n"); } The output: 0: zero 1: one zero 2: two one zero
Yes: double d; printf ("scanf's just returned %d\n", scanf ("%lf", &d));
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');
program#include#include#includevoid main(){int a,b,ans,ch;clrscr();printf("enter the value of a and b");scanf("%d%d",&a,&b);printf("1.Addition");printf("\n2.Subtraction");printf("\n3.Multiplication");printf("\n4. exit");printf("enter your choice");scanf("%d",&ch);switch(ch){case 1:ans=a+b;printf("\nAfter Addition:%d",ans);break;case 2:ans=a-b;printf("\nAfter Subtraction:%d",ans);break;case 3:ans=a*b;printf("\nAfter Multiplication:%d",ans);break;case 4:exit(0);break;}getch();}
use cout << simple
you can put the printf function inside a if() so that you need not use semicolons. for eg to print my name, if(printf("My Name is Maheedharan")) {} this will work. try this out...