Ad Code

Responsive Advertisement

Divide the string in n equal parts

Printing the string in n Equal parts

Divide the string in N equal parts

Printing the string in n equal parts:

C Program:

Output 1:

Divide the string in N equal parts output


Output 2:

Divide the string in N equal parts output


From the above program,

ü l=strlen(a) is used to find the length of the string, in the above output the given string is "Dandelions".

ü Length of the above mentioned string is 10.

ü n is the number of parts the string to be divided.

ü div = l/n is used to find the string to be divided and displayed.

In the above mentioned string, 

ü Dandelions need to be divided into 5(n=5) then length=10, so the equal parts of the string to be divided will be div = 10/5 =2.

So the string will be divided as 2 equal.

Output will be as,

ü If the same string need to be divided as 2 i.e., n=2 then then equal parts will be div = 10/2 = 5.

Output will be as,

Post a Comment

0 Comments

Close Menu