Saturday, 20 January 2018

Mixed Data Types | C programs in Mixed data Types | practical c programming


Mixed Data Types

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   

Related Posts:

  • GO TO Statement GO TO Statement This Keyword is used when we want to transfer the control to some point in the program which is not in the normal, step by step sequence of a program.  It takes control from one place to another un… Read More
  • The NOT(!) Operators The NOT(!) Operators So far we have used only the logical operators && and ||.Third operator is the Not operator, written as !. This operator reverses the result of the expression it operates on.For example,if th… Read More
  • Use Of Logical Operators Use Of Logical Operators  C allows usage of three logical operators, namely && ,|| and ! These are to be read as 'AND' ,' OR' and 'NOT' respectively.&&, || allows two or more conditions to be combine… Read More
  • Case Control Structure(SWITCH) Case Control Structure(SWITCH) Introduction:           In real life we are often faced with situations where we are required to make a choice between a number of  alternatives rather than on… Read More
  • Introduction To Functions Introduction To Functions Functions are building blocks of C. The general form of C (User-defined) function is:       Return-type-function-name(parameter list)       parameter declaration &… Read More

0 comments:

Post a Comment