Question

Write a function that takes an array of integers and its size as parameters and prints the two largest values in the array. In this question, the largest value and the second largest value cannot be the same, even if the largest value occurs multiple times. In the first sample, the two largest values are 9 and 8 (even though the value 9 appears twice). In the second sample, all the values are equal and the program recognizes this by printing a special message.

Answer #1

CODE::::

#include <stdio.h>

int main()

{

int size = 10;

int array[size];

int firstMax , secondMax;

int i;

printf("Array data:\n");

for(i=0;i<size;i++) {

scanf("%d",&array[i]);

}

firstMax = array[0] , secondMax = array[1];

for(i=0;i<size;i++) {

if (array[i] > firstMax) {

if(firstMax!=array[i]) {

secondMax = firstMax;

}

firstMax = array[i];

} else if (array[i] > secondMax) {

if(firstMax!=array[i]) {

secondMax = array[i];

}

}

}

printf("Maximum value: %d\n", firstMax);

if(firstMax == secondMax) {

printf("All the values are equal\n");

} else {

printf("Second largest value: %d\n", secondMax);

}

return 0;

}

OUTPUT::::

OUTPUT::::

Questions:
1. Create a VB.NET Console Application that defines a
function Smallest and calls this function from the main program.
The function Smallest takes three parameters, all of the Integer
data type, and returns the value of the smallest among the three
parameters. The main program should
(1) Prompt a message (using Console.WriteLine) to ask the user to
input three integers.
(2) Call the built-in function Console.ReadLine() three times to
get the user’s input.
(3) Convert the user’s input from...

8) Write Python code for a function called occurances that takes
two arguments str1 and str2, assumed to be strings, and returns a
dictionary where the keys are the characters in str2. For each
character key, the value associated with that key must be either
the string ‘‘none’’, ‘‘once’’, or ‘‘more than once’’, depending on
how many times that character occurs in str1. In other words, the
function roughly keeps track of how many times each character in
str1 occurs...

JAVA please
Arrays are a very powerful data structure with which you must
become very familiar. Arrays hold more than one object. The objects
must be of the same type. If the array is an integer array then all
the objects in the array must be integers. The object in the array
is associated with an integer index which can be used to locate the
object. The first object of the array has index 0. There are many
problems where...

**please write code with function definition taking in input and
use given variable names** for e.g. List matchNames(List
inputNames, List secRecords)
Java or Python
Please Note:
* The function is expected to return a
STRING_ARRAY.
* The function accepts following
parameters:
* 1. STRING_ARRAY
inputNames
* 2. STRING_ARRAY
secRecords
*/
Problem Statement
Introduction
Imagine you are helping the Security Exchange Commission (SEC)
respond to anonymous tips. One of the biggest problems the team
faces is handling the transcription of the companies reported...

Using the following code perform ALL of the tasks below in
C++:
-------------------------------------------------------------------------------------------------------------------------------------------
Implementation:
Overload input operator>> a bigint in the following
manner: Read in any number of digits [0-9] until a semi colon ";"
is encountered. The number may span over multiple lines. You can
assume the input is valid.
Overload the operator+ so that it adds two bigint together.
Overload the subscript operator[]. It should return the i-th
digit, where i is the 10^i position. So the first...

Use Python to Complete the following on a single text file and
submit your code and your output as separate documents. For each
problem create the necessary list objects and write code to perform
the following examples:
Sum all the items in a list.
Multiply all the items in a list.
Get the largest number from a list.
Get the smallest number from a list.
Remove duplicates from a list.
Check a list is empty or not.
Clone or copy...

**[70 pts]** You will be writing a (rather primitive) online
store simulator. It will have these classes: Product, Customer, and
Store. All data members of each class should be marked as
**private** (a leading underscore in the name). Since they're
private, if you need to access them from outside the class, you
should do so via get or set methods. Any get or set methods should
be named per the usual convention ("get_" or "set_" followed by the
name of...

1.The sample mean is an unbiased estimator for
the population mean. This means:
The sample mean always equals the population mean.
The average sample mean, over all possible samples, equals the
population mean.
The sample mean will only vary a little from the population
mean.
The sample mean has a normal distribution.
2.Which of the following statements is
CORRECTabout the sampling distribution of the
sample mean:
The standard error of the sample mean will decrease as the
sample size increases....

MATHEMATICS
1. The measure of location which is the most likely to
be
influenced by extreme values in the data set is the a. range
b.
median c. mode d. mean
2. If two events are independent, then a. they must be
mutually
exclusive b. the sum of their probabilities must be equal to one
c.
their intersection must be zero d. None of these alternatives
is
correct. any value between 0 to 1
3. Two events, A and B,...

Wal-Mart Online
Wal-Mart is one of the largest companies in America. It is
definitely the largest retailer, both in terms of the number of
stores (8,970 worldwide in 2011) and the level of sales ($419
billion from the 2011 Annual Report). By pushing suppliers to
continually reduce costs, Wal-Mart is known for pursuing low prices
and the stores often attract customers solely in-terested in lower
prices. With Wal-Mart’s expansion into groceries, the company has
be-come the largest retail grocer in...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 10 minutes ago

asked 14 minutes ago

asked 41 minutes ago

asked 45 minutes ago

asked 48 minutes ago

asked 49 minutes ago

asked 49 minutes ago

asked 51 minutes ago

asked 51 minutes ago

asked 52 minutes ago

asked 1 hour ago

asked 1 hour ago