# Day 6 Let's Review Hackerrank Solution in C Language

Write a programming solution code to find the Day 6 Let's Review Hackerrank Solution in C Programming Language. So in this hackerrank day 6 Let's Review problem, we have to find the even and odd character of a string. First, we have to print even space of string characters, then write two spaces and, in the end, print the odd number of characters in a single line. Let's understand and find a hackerrank day 6 solution with an example given below.

Suppose the string is programmingwithbasics after solving this programming challenge. We will get the following output. In the below output, we can see that the pormigihais characters are coming on; even places and rgamnwtbsc are occurring in an odd place, and between them is two spaces. This is logic to solve a Day 6 Hackerrank Solution in C and other programming languages. As we know that this problem belongs to 30 days of code hackerrank challenge.

## Day 6 Let's Review Hackerrank Solution in C- Table of Content

1. Day 6: Let's Review- Task
2. Input Format
3. Constraints
4. Output Format
5. Sample Input
6. Sample Output
7. hackerrank day 6 solution in c
8. day six hackerrank solution
9. Output

### Day 6 Let's Review- Task

Given a string, S, of length N that is indexed from 0 to N-1, print its even-indexed and odd-indexed characters as two space-separated strings on a single line (see the Sample below for more detail).

Note: 0 is considered to be an even index.

#### Input Format

The first line contains an integer, T (the number of test cases).
Each line i of the T subsequent lines contain a String, S.

#### Constraints

1<=T<=10
2<=length of S<=10000

#### Output Format

For each String Sj (where 0<=j<=T-1), print Sj's even-indexed characters, followed by a space, followed by Sj's odd-indexed characters. Get a Day 6 Let's Review Hackerrank Solution in C programming language.

2
Hacker
Rank

Hce akr
Rn ak

#### Explanation

Test Case 0: S="Hacker"

S = "H"
S = "a"
S = "c"
S = "k"
S = "e"
S = "r"

The even indices are 0, 2, and 4, and the odd indices are 1, 3, and 5. We then print a single line of 2 space-separated strings; the first string contains the ordered characters from S's even indices (Hce), and the second string contains the ordered characters from S's odd indices (akr). Let's check the second test case of Hackerrank Day 6 Solution in C

Test Case 1: S="Rank"

S = "R"
S = "a"
S = "n"
S = "k"

The even indices are 0 and 2, and the odd indices are 1 and 3. We then print a single line of 2 space-separated strings; the first string contains the ordered characters from S's even indices (Rn), and the second string contains the ordered characters from S's odd indices (ak).

## Hackerrank Day 6 Solution in C Code

Below is the Day 6 Hackerrank Solution in C Programming.

``````#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main()
{
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n; char s;
scanf("%d",&n);

for(int i=0;i<n;i++)
{
scanf("%s",s);
myFunction(s);
}
}

void myFunction(char s[])
{
for(int i=0;i<strlen(s);i++)
{
if (i%2 == 0)
{
printf("%c",s[i]);
}
}

printf(" ");

for(int i=0;i<strlen(s);i++)
{
if (i%2 != 0)
{
printf("%c",s[i]);
}
}

printf("\n");
}``````

### Explanation of Day 6 Let's Review Hackerrank Solution in C

Let's Review Hackerrank Solution in C explanation is here. We first divide the string into even and odd number as we can see that in the string "Hacker," H is in even place, and a is in an odd place and so on. So our string is "Hacker" can be divided by even (H), odd (a), even (c), odd (k), even (e), odd (r).

Step 1: The first step of Hackerrank Day 6 Solution in C. Run the first loop up to the size of the string and find the even character and print the even place character and print like below.

``````for(int i=0;i<s.size();i++)
{
if(i%2==0)
cout<<s[i];
}``````

after the first loop complete print space so we can print and separate the second loop. This is the last step of Day 6 Hackerrank Solution in C.

``cout<<" ";``

Step 2: Run the second loop up to the size of the string and find the odd place character and print the odd place character and print like below.

``````for(int i=0;i<s.size();i++)
{
if(i%2!=0)
cout<<s[i];
}``````

At the end print the new line for the next input to the early and next input print in the new line.

``cout<<endl;``

All solution provided here is in C. If you want these solutions in C++ and Java. Get hackerrank day 6 solution in java and C++ with the full explanation.

### Similar to Day 6 Hackerrank Solution in C

Previous Post
Next Post

#### post written by: Ghanendra Yadav

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.

1. can u explain ur code above

1. 2. Day 6 solution in java

udit.sehra77@gmail.com

3. can u explain these 4 lines of code pls..like is t is the length of string or what ?
int t;
cin>>t;
while(t--)
{