what is format specifiar %s

 if we want to print whole strings value in one time then we directly use %s in printf


#include <stdio.h>


int main()

{ int index = 0;

    //char name[] = {'r','o','h','i','t','\0'};

    //char surname [] = {'p','a','r','m','a','r', '\0'};

 // you can choose upper 2 lines or below 2 lines but comment any two lines

   

   char name [] = "rohit";

    char surname [] = "parmar";

   

   printf("%s\n", name);

   while ( name[index]!='\0'){

       printf("%c", name[index]);

       index++; }

       

       index =0;

    while ( surname[index]!='\0'){

       printf("%c", surname[index]);

       index++; } 


    return 0;

}

Comments

Popular posts from this blog

Factors : using C

Cross shaped pattern

Factorial ! calculation