# C Programming – HackerRank Solution | Withdrawal from Bank |

### (HackerRank) Write a Modular C Programming code to solve Withdrawal from Bank.There is a district named Singrauli in MP. People from neighbouring villages come at this district bank in the district to withdraw money.

There is a district named Singrauli in MP. People from neighbouring villages come at this district bank in the district to withdraw money. Everyone made a huge crowd in front of the bank. By seeing the crowd bank manager is annoyed as it is disturbing other activities. So, the manager plans to divide the crowd into 2 different lines. First-line includes those who wish to withdraw through cheque. Second-line includes withdrawal through withdrawal slip. Assume codes for withdrawing through cheque as C, through withdrawal slip as W, can you help the Manager to divide the crowd?

Input Format

First Line indicates N number of customers visiting the Bank.

Next N lines indicate Name of account holder and Code for type of Withdrawal (separated by a space).

Constraints

0 < N <= 100

Name of Account holder is String. Code for Type of Withdrawal is single character.

Output Format

First Line indicates Names of account holders with code for withdrawing through cheque.

Second Line indicates Names of account holders with code for withdrawing through slip.

Sample Input 0

```7
Ajay C
Raj W
Rani C
Rahul C
Deepa W
Vani C
```

Sample Output 0

```Ajay Rani Rahul Vani
```

Sample Input 1

```3
Ram W
Kumar W
Biswas W
```

Sample Output 1

```Line 1 Empty.
Ram Kumar Biswas```

CODE:

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

struct node{
char name[20];
char code;
};
typedef struct node *NODE;
int main() {
int n;
scanf("%d",&n);
//printf("%s %c\n",newnode->name,newnode->code);
if(cur==NULL)
{
}
else{
{
}
}
}
{
if(cur==NULL)
{
printf("Line %d Empty.",i);
}
else{
while(cur!=NULL)
{
printf("%s ",cur->name);
}
}
}
{
while(cur!=NULL)
{
if(cur->code=='W')
{
NODE newnode=malloc(sizeof(struct node));
strcpy(newnode->name,cur->name);
newnode->code=cur->code;
{
}
else{
{
}
}
}
}
}
{
while(cur!=NULL)
{
if(cur->code=='W')
{
{
free(cur);
}
else{
free(cur);
}
}
else{
prev=cur;
}
}
}
```

OUTPUT

```Congratulations, you passed the sample test case.

Click the Submit Code button to run your code against all the test cases.

Input (stdin)

7
Ajay C
Raj W
Rani C
Rahul C
Deepa W
Vani C

Ajay Rani Rahul Vani
Expected Output

Ajay Rani Rahul Vani

Please find some more codes of Loops, Condition Statements, 1D Arrays, 2D Arrays, Strings, Pointers, Data Structures, Files, Linked lists, Stacks, Queues, Binary Trees, MISC, Solved model question papers & Hacker Rank all solutions on the below page:

Top 100+ C Programming codes – KLE Technological University