Mixed Data Types in C language
Posted by 
Ravi Kumar at Sunday, September 11, 2011
| Share this post: | 
Mixed Data Types in C language:
   
It ispermitted 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 GUPTA
                         ANIL KUMAR GUPTA
                                        ANIL KUMAR 
                     ANIL
                     ANIL KUMAR
                     ANIL KUMAR GUPTA  
note: There are some space errors in the output, because blogger does not allow  too much space between characters. Execute the program in ur system







