Friday, January 29, 2016

Divide given string into three equal parts using for loop.

C program to divide given string into three equal parts using for loop.


#include<stdio.h>
#include<string.h>
int main()
{
 char str[30];
 int i,j,cnt=0;
 gets(str);
 //Read 30 characters to avoid extra characters in output. 
 for(i=0; i<3; i++)
 {
  for(j=0; j<10; j++)
   printf("%c",str[cnt++]);
  printf("\n");
 }
 return 0;
}


No comments:

Post a Comment