Copyable code
//Include the needed header
#include<stdio.h>
//Method searchArray()
int searchArray(int query, int nValue, int priceArray[])
{
//Declare and initialize counter
int counter = 0;
//Loop to iterate through n values
for (int index = 0; index<nValue; index++)
{
//Check condition
if (priceArray[index] == query)
//Increment
counter
counter++;
}
//Return counter
return counter;
}
//Method main()
int main()
{
//Declare a variable for n
int nValue;
//Declare a variable for m
int mValue;
//Read input values
scanf("%d %d", &nValue, &mValue);
//Array to hold food prices
int priceArray[150000];
//Loop to iterate through n values
for (int index = 0; index<nValue; index++)
{
//Read input
scanf(" %d",
&priceArray[index]);
}
//Loop to iterate through m values
for (int index1 = 0; index1<mValue; index1++)
{
//Declare a variable for
query
int query;
//Declare a variable for
counter
int counter;
//Read input
scanf(" %d", &query);
//Call searchArray()
method
counter = searchArray(query,
nValue, priceArray);
//Display result
printf("%d ", counter);
}
}
C language Thank you Jojo is going to a restaurant. There are N foods listed in...
Write in C language . Thank you Count Sheep Jojo is having problem to sleep at night. He can't fall asleep and it makes him feel tired every day. Having this problem, Jojo told his friend Bibi, and Bibi advised him to do sheep counting while he tries to sleep. Jojo decided to try using this trick for N nights, to test its effectiveness. Jojo realized that he would fall asleep if he imagined a total of 10 white sheep....
Write in C language Diamond Jojo want to propose to Lili. Jojo think he should give Lili a diamond when he proposed to her. But Jojo is having problem to choose the diamond so he asked you to show him diamonds based on the size he told you Format Input The input consists of only one integer S, denotes the size of the diamond. Format Output Show the diamond Jojo want to see, Constraints 4 SS S 30 Page 1...
C Programming Language Problem Title: Discount Jojo is browsing the internet while suddenly he sees an ad about the new cafe. The promotion is if the price of an item is N dollars, then you can buy the second item for half the price, the third item for a quarter of the original price, and so on, but if it becomes less than M dollars, then you have to pay M dollars. He wonders how much he has to pay...
write in C language Decoration Lights Jojo is currently working in an office as a security. Every night, after everyone returned home, he needs to make sure all decoration lights in the office is turned off. The decoration lights are unique: each of them has a timer that will switch the light on or off every two seconds. The lights are also arranged so well that each two neighboring lights will have different state (on/off). As long as the timer...
C Programming Language The code below matches the sample input/output but is marked wrong. Are there other ways to do this problem? The focus is on recursion and functions. #include<stdio.h> int joCheck(unsigned long long int number) { if(number % 7 == 0 || number % 8 == 0) { return 1; } else return 0; } int main() { int cases = 0; scanf("%d", &cases); for(int i = 1; i<=cases; i++) { unsigned long long int number; scanf("%d", &number); if(joCheck(number)...
Java problem In this problem, the first input is a positive integer called n that will represent the number of lines to process. The lines to be processed have one or more integers separated by whitespaces. For each of these lines, you must output: The minimum value of the integers The maximum value of the integers The sum of the integers It is worth to mention that the number of integers of each line is not known a priori and...
C Programming Language Problem Title : Climbing Stairs Bibi climbs stairs of a multi-leveled building. Every time Bibi climbs a set of stairs, she counts the steps starting from 1 to the number of steps in that particular set of stairs while climbing the stairs. For example if she climbs two set of stairs, the first containing 5 steps and the second containing 3 steps, she will say 1, 2, 3, 4, 5, 1, 2, 3 and the total number...
Use c language Project Euler #5: Smallest multiple H HackerRank This problem is a programming version ofProblem 5 from projecteuler.net 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible(divisible with no remainder) by all of the numbers from 1 to N? Input Format First line contains T that denotes the number of test cases. This is followed by...
C++ You're given the pointer to the head nodes of two linked lists. Compare the data in the nodes of the linked lists to check if they are equal. The lists are equal only if they have the same number of nodes and corresponding nodes contain the same data. Either head pointer given may be null meaning that the corresponding list is empty. Input Format You have to complete the int CompareLists (Node headA, Node* head B) method which takes...
C Programming Language Problem Title: Komodo National Park Do You know that Komodo National Park, located in Nusa Tenggara Timur (NTT), is a World Heritage Site by UNESCO, the specialized agency under United Nations (UN). One day, Lili and Bibi were on vacation on one of the islands in the Komodo National Park area and they just realized that they were living alone on that island because the cot- tage owner was completing his unfinished business on the main island....