P167. Interchange 1st and 3rd string.

 

#include<stdio.h>

#include<string.h>

void main()

{

        char c[5][10],cp[10];

        int i,ele;

        ele=sizeof(c)/sizeof(c[0]);

 

        printf("Enter the strings \n");

        for(i=0;i<ele;i++)

                scanf("%s",c[i]);

        printf("\n");

 

        strcpy(cp,c[0]);

        strcpy(c[0],c[2]);

        strcpy(c[2],cp);

 

        printf("\n");

        for(i=0;i<ele;i++)

                printf("%s\n",c[i]);

}

Comments