answersLogoWhite

0

== == What is printf in c or prototype of printf with example

(q) What is prototype of printf function ? Explain each term.

Ans: Prototype of printf function is :

int printf( const char *format ,…)

Explanation of each term :

Parameter of printf function is :

(three continuous dots) : It is called ellipsis. It indicates the variable number of

arguments.

Example of ellipsis:

#include

void ellipsis(int a,...);

void main()

{

int a=5,b=10;

clrscr();

ellipsis(a,b);

getch();

}

void ellipsis(int a,...)

{

printf("%d ",a);

}

Output:5

So printf function can have any number of variables as an argument.

User Avatar

Wiki User

16y ago

What else can I help you with?

Continue Learning about Engineering

Why isn't main a keyword in c?

Neither is printf, stderr or NULL. Certainly, they are important words, but not keywords.


What is a token in c?

Anything that you can't put whitespace between. The indivisible elements of a program. Example: printf("Sup world %d",variable); Tokens: (7 total) printf ( "Sup World %d" , variable ) ;


How do you write c program to identify keywords using transition table?

#include#include#includevoid keyw(char str[10]){if(strcmp("for",str)==0)printf("%s is a keyword",str);else if(strcmp("while",str)==0)printf("%s is a keyword",str);else if(strcmp("char",str)==0)printf("%s is a keyword",str);else if(strcmp("int",str)==0)printf("%s is a keyword",str);else if(strcmp("if",str)==0)printf("%s is a keyword",str);else if(strcmp("else",str)==0)printf("%s is a keyword",str);elseprintf("%s is an identifier",str);printf("\n");}main(){FILE *f1,*f2,*f3;char c,str[10];int num[100],ln=0,tvalue=0,i=0,j=0,k=0;printf("Enter a C program expression");f1=fopen("input.c","w");while((c=getchar())!=EOF)fputc(c,f1);f1=fopen("input.c","r");f2=fopen("identifier.txt","w");f3=fopen("specialchars.txt","w");while((c=fgetc(f1))!=EOF){if(isdigit(c)){tvalue=c-'0';c=fgetc(f1);while(isdigit(c)){tvalue=tvalue*10+c-'0';c=fgetc(f1);}num[i++]=tvalue;ungetc(c,f1);}else if(isalpha(c)){fputc(c,f2);c=fgetc(f1);while((isdigit(c))isalpha(c)c==' 'c=='$'){fputc(c,f2);c=fgetc(f1);}fputc(' ',f2);ungetc(c,f1);}else if(c==' 'c=='\t');else if(c=='\n')ln++;elsefputc(c,f3);}fclose(f1);fclose(f2);fclose(f3);printf("Numbers in the program are \n");for(j=0;j


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

#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); } }


Simulation of finite state automata to recognize the tokens of control statement?

#include<stdio.h> #include<conio.h> #include<string.h> void main() { char a[8];int s,i,flag=0,loc1=0,loc2=0,j; clrscr(); printf("Enter any string\n"); gets(a); for(i=0;i<8;i++) { int ch=a[i]; if(ch!=32) { loc2=i; flag++; } if(ch==32) { s=flag; flag=0; switch(s) { case 2: if(a[loc1]=='i' && a[loc2]=='f') printf("STRING HAS if AS A KEYWORD"); break; case 3: if(a[loc1]=='f' && a[loc1+1]=='o' && a[loc2]=='r') printf("STRING HAS for AS A KEYWORD"); break; default: printf("not our case"); } } } getch(); }

Related Questions

Why isn't main a keyword in c?

Neither is printf, stderr or NULL. Certainly, they are important words, but not keywords.


How is the 'sizeof' keyword in a c program used to determine the amount of space of a variable?

It is 'sizeof'. Example: printf ("sizeof(int)=%d\n", sizeof (int));


What is a token in c?

Anything that you can't put whitespace between. The indivisible elements of a program. Example: printf("Sup world %d",variable); Tokens: (7 total) printf ( "Sup World %d" , variable ) ;


Can you use nested printf?

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


How do you write c program to identify keywords using transition table?

#include#include#includevoid keyw(char str[10]){if(strcmp("for",str)==0)printf("%s is a keyword",str);else if(strcmp("while",str)==0)printf("%s is a keyword",str);else if(strcmp("char",str)==0)printf("%s is a keyword",str);else if(strcmp("int",str)==0)printf("%s is a keyword",str);else if(strcmp("if",str)==0)printf("%s is a keyword",str);else if(strcmp("else",str)==0)printf("%s is a keyword",str);elseprintf("%s is an identifier",str);printf("\n");}main(){FILE *f1,*f2,*f3;char c,str[10];int num[100],ln=0,tvalue=0,i=0,j=0,k=0;printf("Enter a C program expression");f1=fopen("input.c","w");while((c=getchar())!=EOF)fputc(c,f1);f1=fopen("input.c","r");f2=fopen("identifier.txt","w");f3=fopen("specialchars.txt","w");while((c=fgetc(f1))!=EOF){if(isdigit(c)){tvalue=c-'0';c=fgetc(f1);while(isdigit(c)){tvalue=tvalue*10+c-'0';c=fgetc(f1);}num[i++]=tvalue;ungetc(c,f1);}else if(isalpha(c)){fputc(c,f2);c=fgetc(f1);while((isdigit(c))isalpha(c)c==' 'c=='$'){fputc(c,f2);c=fgetc(f1);}fputc(' ',f2);ungetc(c,f1);}else if(c==' 'c=='\t');else if(c=='\n')ln++;elsefputc(c,f3);}fclose(f1);fclose(f2);fclose(f3);printf("Numbers in the program are \n");for(j=0;j


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

#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); } }


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",&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(); }


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 the prototype of printf function?

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


Simulation of finite state automata to recognize the tokens of control statement?

#include<stdio.h> #include<conio.h> #include<string.h> void main() { char a[8];int s,i,flag=0,loc1=0,loc2=0,j; clrscr(); printf("Enter any string\n"); gets(a); for(i=0;i<8;i++) { int ch=a[i]; if(ch!=32) { loc2=i; flag++; } if(ch==32) { s=flag; flag=0; switch(s) { case 2: if(a[loc1]=='i' && a[loc2]=='f') printf("STRING HAS if AS A KEYWORD"); break; case 3: if(a[loc1]=='f' && a[loc1+1]=='o' && a[loc2]=='r') printf("STRING HAS for AS A KEYWORD"); break; default: printf("not our case"); } } } getch(); }


Where the printf statements are stored in memory?

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; }


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; } }