Mixed Data Types
It is permitted to mix data types in one printf statement: printf("%d%f%s%c",a,b,c,d);printf uses its control string to decide how many variables to be printed and what their types are.
Program: /* printing of characters and strings*/
main()
{
char x='A'
static char name[20]="ANIL KUMAR";
printf("%c\n%3c\n%5c\n",x,x,x);
printf("%3c\n%c\n",x,x,x);
printf("\n");
printf("OUTPUT OF STRINGS\n\n");
printf("%s\n",name);
printf("%20s\n",name);
printf("%.5s\n",name);
printf("-20.10s\n",name)
printf("%5s\n",name);
}
Output: output of characters
A
A
A
A
A
output of strings
ANIL KUMAR
ANIL KUMAR
ANIL KUMAR
ANIL
ANIL KUMAR
ANIL KUMAR
No comments:
Post a Comment