Answer to Question #165335 in C for B nethravathi

Question #165335

You have got homework in N subjects for each homework you require a minimum of min energy and consume actual energy while doing it.

Example, if for a other home work mini=12 and actuality=10, you require at least 12 energy for starting this homework. If u have 11 energy or less you cannot do this homework.

Calculate the minimum intial energy required to complete all the homework

Note : you can finish the homework in any order you like

Constraints

1<=N<=10^5

1<=actual [i]<=10^3

1<=min[I]<=10^3


1
Expert's answer
2021-02-21T19:50:46-0500
#include <stdio.h>
#include <stdlib.h>
#include <time.h> 
void minimumInitialEnergy(int lower, int upper, int count) { 
    int Sum = 0; 
    for (int i = 0; i < count; i++) { 
        Sum += (rand() % (upper - lower + 1)) + lower; 
    } 
    printf("The initial Energy which required for %d subjects is %d", count, Sum);
} 
int main() {
    int N;
    printf("Enter the number of subjects: ");
    scanf("%d", &N);
    minimumInitialEnergy(1, 1000, N);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS