Questions: 1 978

Answers by our Experts: 1 850

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!

Search & Filtering

Mr. Sharma has travel plans. He wants to know the distance travelled in kilometers [KM] to



destination on October 15th. Initially Mr. Sharma travels a fixed distance of 40 KM from his



house to Airport. If October 15th is a Full working day he travels 2200 KM to attend a



Conference at Delhi, if it is a half working day he travels 350 KM to attend a Conference at



Chennai, if it is a Holiday he travels 600 KM for a Holiday in Goa.



Following are requirements to solve the problem



a. The working day status i.e., Full working day, half working day or Holiday on October 15th



has to be captured.



b. Check for the given conditions and compute the total distance



c. Display the distance travelled in KM along with the destination in an appropriate message.

make a c program that asks the user to enter two numbers. Then, get the total and DISPLAY"I LOVE MY PARENTS" if the sum is more than or equal to 25, otherwise DISPLAY "I WILL NEVER GIVE UP!". And show which number is greater and lower.

number of elements in an array between upper and lower bounds program

Write a C program that creates a 4x4 2d array, fill it with user-defined values and display (separately) the sum of the diagonal as well as the upper and lower triangular elements.


d ut ut ut

Lt d ut ut

Lt Lt d ut

Lt Lt Lt d


where: ut means upper triangular

Lt means lower triangular

d means diagonal elements


Write a program in C that prompt the user to enter temperature in either degrees Celsius or Fahrenheit. These program then computes to a different unit. Use function.

Using linked list , take two input polynomials from user and create a new polynomial such that it first multiplies the first polynomial by x^(degree of second polynomial) and then adds it to the second polynomial .


Write a program in c language that could prompt the user to select a mathematical figure either circle or rectangle . The program then compute the perimeter of the figure.

Cubes and Squares

by CodeChum Admin

You can also make a list of numbers, ey? Let's go and have some fun in tweaking the values of each element, but let's give it some twist to add on some fun to the code.


Let's have a go at it!


Instructions:

  1. An array containing 40 integer elements is already provided for you in the code editor below.
  2. Using loops and conditions, print out the cube of the array element if it is a positive number, and print out the square of the number if it is negative. Each result must be printed out separately by each line.

Output

The squares and cubes of the elements in the array.

4
1
1
8
27
.
.
.

Miss Ural wants to buy colors for Holi, and that too, at the cheapest cost!

There are N shops selling colors near Ural's house, where the i′th shop sells colors at rate of Ri for one unit. Also, i′th shop is located at a distance of Di kilometers from her house. Life was simple, but then petrol and fuel prices soared up. The current price of petrol to travel one kilometer is K

Find the minimum cost at which Miss Ural can buy one unit of color. she does not need to return back home.


  • The first line of input contains T, number of test cases in a file.
  • The next line contains two integers, N and K, as described in the problem statement.
  • The next line contains N space separated integers, denoting Di, i.e. distance of the shop.
  • The next line contains N space separated integers denoting Ri, i.e. rate of the color.


For test case, output minimum cost to purchase 1 unit of color.


  • 1≤T≤10^5
  • 1≤N≤10^5
  • Sum of N over all T in a test file does not exceed 10^6.
  • 1≤Ri,K,Di≤10^9

You are given an array of N non-negative integers: A1, A2, ..., AN. An alternating subsequence is a subsequence in which the indices of any two consecutive elements differ by exactly two in the original array. That is, if Ai1, Ai2, ..., Aik is some subsequence, then for it to be an alternating subsequence, (i2 - i1 = 2), (i3 - i2 = 2), and so on should all hold true. Among all alternating subsequences, find the one which has maximum sum of elements, and output that sum.


Input

The first line of the input contains an integer T denoting the number of test cases.


The first line of each test case contains an integer N denoting the number of elements in the array.


The second line contains N space-separated integers A1, A2, ..., AN denoting the array A.


Output

For each test case, output a single line containing the answer.


Note

A subsequence with only a single integer is also an alternating subsequence.

Constraints

1 ≤ T ≤ 10

1 ≤ N ≤ 105

0 ≤ Ai ≤ 105


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS