# C Programming – HackerRank Solution | MIDDLE-CLASS FAMILY |

### (HackerRank) Write a Modular C Programming code to solve MIDDLE-CLASS FAMILY, A middle class family would always like to spend the money wisely, because of their financial status.

A middle class family would always like to spend their money wisely, because of their financial status. They can’t afford to purchase luxurious items, unlike the Rich Class family. Even if they do, they do it very occasionally. In order to keep track of the expenditures of the entire year, the middle-class family maintains a record of how much they spent every month of that year. Consider for the year 2019, a family maintains a record of expenditure for each month. At the end of the year, the family would like to know the following about their expenditure. Which month of the year they spent more? (display month number) Which month of the year they spend less? (display month number). Which are the months they spent more than 35000 rupees? (display month number). Apply Problem solving framework to solve the said middle-class family problem.

Input Format

Number of months in first line.

Expenditure every month in next line.

Constraints

Number of months are fixed to 12.

Starting from 1 to 12, 1 indicates January month, 2 indicates February month and so on upto 12 indicates December month.

Output Format

First line should display month number for spent more.

Second line should display month number for spent less.

Third line should indicate month numbers spent more than 35000.

Sample Input 0

12
49832 34829 21102 58222 10238 33390 12220 47472 25000 11200 34000 29005

Sample Output 0

4
5
1 4 8

Sample Input 1

5

Sample Output 1

Expenditure should be for 12 months.

CODE:

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

struct node{
int spent;
};
typedef struct node *NODE;
NODE create_node();
int main() {
int n;
scanf("%d",&n);
if(n==12)
{
return newnode;
}
{
NODE newnode=create_node();
scanf("%d",&newnode->spent);
else{
}
}
{
int max=cur->spent;
int i=1;
int count=1;
while(cur!=NULL)
{
if(maxspent)
{
max=cur->spent;
i=count;
}
count++;
}
printf("%d\n",i);
}
{
int min=cur->spent;
int i=1;
int count=1;
while(cur!=NULL)
{
if(min>cur->spent)
{
min=cur->spent;
i=count;
}
count++;
}
printf("%d\n",i);
}
{
int count=1;
while(cur!=NULL)
{
if(cur->spent>35000)
{
printf("%d ",count);
}
count++;
}
}

OUTPUT

Congratulations, you passed the sample test case.

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

Input (stdin)

12
49832 34829 21102 58222 10238 33390 12220 47472 25000 11200 34000 29005

4
5
1 4 8
Expected Output

4
5
1 4 8

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

#### Welcome to FactsPrime

Sorry, We have detected that you have activated Ad-Blocker. Please Consider supporting us by disabling your Ad Blocker, It helps us in maintaining this website. To View the content, Please disable adblocker and refresh the page.

Thank You !!!