Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write the code in C language and use comments where necessary. write in c language, and you can store the information in txt file. In

write the code in C language and use comments where necessary.

image text in transcribed

write in c language, and you can store the information in txt file.

image text in transcribed

In Istanbul stock exchange (Borsa Istanbul), you are eligible to buy only 1 unit of stock only 1 tir time, moreover, you, then, are able to sell it at a later time. To buy and sell you should wait for the close of trading for that day. Your aim is to maximize your profit. Thus, that is better you buy a unit of stock on a lower price and sell it back on a higher price. The lowest and highest prices may not always work as expected. Since, in a stock market there can be descents as well as accents (see below figure). 11 10 9 3 4 8 7 10 11 Price Change We should find a sequence of days over which the net change from the first day to the last is maximum. It is asked you to dig for some contiguous days whose values have the largest sum. Your client is expecting to see those days average value their sum, and when best to buy and sell. See the below example, i.e., sixteen days of Borsa Istanbul values. At most 100 days of data might be found in a text file. Ex: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 A 13-3-25 20-3-16 -23 18 20 -7 12 -5 -22 15-47 A[8.. 11) Sum = 43 Buy before day 8 (after day 7). sell after day 11. AVG = 10.75 Example Run#1: Buy before day 8 (after the day 7 ends) sell after day 11 (before the day 12 begins). Sum of these 4 days: 43 Average value for these 4 days: 10.75 In Istanbul stock exchange (Borsa Istanbul), you are eligible to buy only 1 unit of stock only 1 time, moreover, you, then, are able to sell it at a later time. To buy and sell, you should wait for the close of trading for that day. Your aim is to maximize your profit. Thus, that is better you buy a unit of stock on a lower price and sell it back on a higher price. The lowest and highest prices may not always work as expected. Since, in a stock market there can be descents as well as accents (see below figure). 11 10 9 8 Day Price Change 0 1 10 11 1 2 7 -4 3 10 3 4 6 -4 7 6 0 1 2 3 4 We should find a sequence of days over which the net change from the first day to the last is maximum. It is asked you to dig for some contiguous days whose values have the largest sum. Your client is expecting to see those days average value, their sum, and when best to buy and sell. See the below example, i.e., sixteen days of Borsa Istanbul values. At most 100 days of data might be found in a text file. Ex: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 -3 -16 -23 18 20 -7 12 -5 -22 15 -4 7 . 13 -3 -25 20 A[8.. 11] Sum = 43 Buy before day 8 (after day 7), sell after day 11. AVG = 10.75 Example Run#1: Buy before day 8 (after the day 7 ends) sell after day 11 (before the day 12 begins). Sum of these 4 days: 43 Average value for these 4 days: 10.75

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

Did you add the logo at correct size and proportion?

Answered: 1 week ago