Write a program using two-dimensional arrays that determines
the highest and lowest of the 12 input values.
Example:
Enter 12 numbers:
13 15 20 13 35 40 16 18 20 18 20 14
highest: 40
lowest: 13



Write a program using two-dimensional arrays that determines the highest and lowest of the 12 input..

Answer / sreejesh1987

// Why 2D array? Solution with 1D array
#include<stdio.h>
#include<conio.h>
void main()
{
int i,a[11],min,max;
clrscr();
printf("Enter Twelve numbers:");
for(i=0;i<12;i++)
scanf("%d",&a[i]);
min=max=a[0];
for(i=0;i<12;i++)
{
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
}

printf("\nHighest:%d,Lowest:%d",max,min);

getch();
}

Is This Answer Correct ?    35 Yes 18 No

Post New Answer

More C++ Code Interview Questions

Code for Easily Using Hash Table?

0 Answers  


Faster Computers Suppose you have a computer that requires 1 minute to solve problem instances of size 1000. What instance sizes can be run in 1 minute if you buy a new computer that runs 1000 times faster than the old one, assuming the following time complexities T(n) for our algorithm? (a) T(n) = O(n). (b) T(n) = O(n3). (c) T(n) = O(10n).

1 Answers   Qatar University,


Implement a command console for changing settings on a particular object. The command console should allow you to enter a string and will return the response (very similar to a terminal session). The commands are as follows: SET propertyname=newvalue will change the target object’s member named “propertyname” to have a value equal to “newvalue”. If the input value is incompatible (i.e. an int being set to a string), print out an appropriate error message. GET propertyname will print out the current value of the target object’s member named “propertyname”. GET * will print out a list of all target object members and their current values. The system should be extensible for future commands and should accept an arbitrary object, such that another developer could insert another object into the system and rely on the command console to get and set the properties correctly.

0 Answers   ABC, Guidance Software,


write a function that reverse the elements of an array in place.The function must accept only one pointer value and return void.

0 Answers   HCL, SRCASW,


what is virtual constroctor ? give an exam for it?-(parimal dhimmar)

2 Answers  






Perform the functionality of 2-D array through 1-D array and in it the functions to be performed were: (1) Display the array in 2-D format (2) Display a particular element (3) Display a particular row (4) Display a particular column

1 Answers   Nagarro,


Display Pattern: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 &#8230;

2 Answers   Mind Tree,


Write a program using one dimensional array that accept five values from the keyboard. Then it should also accept a number to search. This number is to be searched if it among the five input values. If it is found, display the message “Search number is found!” otherwise, display “Search is lost”. Example: Enter 5 numbers: 10 15 20 7 8 Enter number to search: 7 Search number is found!

2 Answers   College School Exams Tests,


#include<stdio.h> #include<conio.h> void main() { char str[10]; int,a,x,sw=0; clrscr(); printf("Enter a string:"); gets(str); for(x=0;x<=a;a++); for(x=0;x<=a;x++) { if(str[x]==str[a-1-x]) { sw=1; } else sw=0; } if(sw==10 printf("The entered string is palindrome:"); else printf("The entered string is not a palindrome:); } getch(); } wht would be the explanation with this written code???

2 Answers  


create a stucture student containing field for roll no,class,year and marks.create 10 student annd store them in a file

0 Answers   HCL,


Create a program to read two random data set in two files named data1.txt and data2.txt manifold contains integer numbers, whereas data2.txt file contains the float type numbers. Simpanlahmasing each into 2 pieces of data that is an array of type integer array and an array of type float, then calculate the average numbers in the second array.

0 Answers  


Write a C/C++ program that connects to a MySQL server and displays the global TIMEZONE.

0 Answers   Facebook, Webyog, Wipro,


Categories