ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C++  >>  C++ General
 
 


 

 
 STL interview questions  STL Interview Questions
 OOPS interview questions  OOPS Interview Questions
 C++ General interview questions  C++ General Interview Questions
Question
Write a program that read 2o numbers in and array and 
output the second largest number. Can anybody help??
 Question Submitted By :: Doukiks
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Write a program that read 2o numbers in and array and output the second largest number. Can anybody help??
Answer
# 1
void main()
{
	int numbers[20];
	int biggest=0, secondBiggest=0;

	for(int index = 0; index < 20; ++index)
	{
		int input;
		cin>>input;

		if(input == biggest)
			continue;
		
		if(input > biggest)
		{
			secondBiggest = biggest;
			biggest = input;
		}
		else if(input > secondBiggest)  
secondBiggest = input;
	}

	cout<<endl<<"Biggest : "<<biggest<<endl<<"Second 
biggest : "<<secondBiggest<<endl;

	getch();
}
 
Is This Answer Correct ?    1 Yes 1 No
Mms Zubeir
 
  Re: Write a program that read 2o numbers in and array and output the second largest number. Can anybody help??
Answer
# 2
ya i above is correct
 
Is This Answer Correct ?    0 Yes 0 No
Sivaraj
 
 
 

 
 
 
Other C++ General Interview Questions
 
  Question Asked @ Answers
 
How to avoid a class from instantiation? Symphony5
What are the differences between a struct and a class in C++? Wipro4
Given a simple program designed to take inputs of integers from 1-1000 and to output the factorial value of that number, how would you test this program? You do not have access to the code. Please be as specific as possible. Microsoft2
Find the second maximum in an array? HCL2
what is the order of initialization for data? TCS4
What is the difference between Pointer and a Reference? When you would use them? Wipro2
What is difference between initialization and assignment? HP4
In a class only declaration of the function is there but defintion is not there then what is that function? Hughes4
What is the Difference between "vector" and "array"? TCS6
How do you know that your class needs a virtual destructor? Lucent3
whats the size of class EXP on 32 bit processor? class EXP { char c1; char c2; int i1; int i2; char *ptr; static int mem; }; Huawei4
1)#include <iostream.h> int main() { int *a, *savea, i; savea = a = (int *) malloc(4 * sizeof(int)); for (i=0; i<4; i++) *a++ = 10 * i; for (i=0; i<4; i++) { printf("%d\n", *savea); savea += sizeof(int); } return 0; } 2)#include <iostream.h> int main() { int *a, *savea, i; savea = a = (int *) malloc(4 * sizeof(int)); for (i=0; i<4; i++) *a++ = 10 * i; for (i=0; i<4; i++) { printf("%d\n", *savea); savea ++; } return 0; } The output of this two programs will be different why?  2
What is Memory Alignment? TCS1
Can you explain the term "resource acquisition is initialization?"  1
How long does this loop run: for(int x=0; x=3; x++) a) Never b) Three times c) Forever Quark9
Find out the bug in this code,because of that this code will not compile....... #include <iostream> #include <new> #include <cstring> using namespace std; class balance { double cur_bal; char name[80]; public: balance(double n, char *s) { cur_bal = n; strcpy(name, s); } ~balance() { cout << "Destructing "; cout << name << "\n"; } void set(double n, char *s) { cur_bal = n; strcpy(name, s); } void get_bal(double &n, char *s) { n = cur_bal; strcpy(s, name); } }; int main() { balance *p; char s[80]; double n; int i; try { p = new balance [3]; // allocate entire array } catch (bad_alloc xa) { cout << "Allocation Failure\n"; return 1; }  2
What are inline functions? Verizon2
is throwing exception from a constructor not a good practice ? Ericsson4
What is Name Decoration? Lucent2
What is Object Oriented programming.what is the difference between C++ and C? Infosys5
 
For more C++ General Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com