GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Tech FAQs  >  Programming  >  C
Go To First  |  Previous Question  |  Next Question 
 C  |  Question 85 of 95    Print  
Finding Two least number in array.
How to find the least two numbers in a single dimension array in a single pass (traversing the elements only once)


  
Total Answers and Comments: 1 Last Update: March 21, 2008     Asked by: ramsoi 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
March 21, 2008 09:33:43   #1  
amitprasad Member Since: March 2008   Contribution: 2    

RE: Finding Two least number in array.
It is very simple man. Just do like taht.

#define LEAST_COMPARE(index, least) list[index] < list[least]

for (index = 0;index < 10;index++)
{
    if (LEAST_COMPARE(index,least))
    {
        second_least = least;
        least = index;
    }
}
list is array of elements and lest and second_least gives the index to array.

 
Is this answer useful? Yes | No

 Related Questions

Latest Answer : NitinMishra is absoulutely right that number generated by rand() is not random. I think this code will serve the purpose.....#include #include int main(){    // Just for example, i have taken the list    ...
Read Answers (5) | Asked by : Ankesh Tiwari

I want to convert a string (ex: 567.2.2.2) into integer or array of integer and i have to check 567 is greater then or less than 256 or not and i have to dispaly. this string is in a file

Q1. write a program to find a given number is armstrong number or not ?Q2write a program which accepts a filename as a command line argument and reverse the contents of the file(i.e first character becomes the last character of the file and so on ?Q3 how can i call a function given its name as a string ?Q4 How to swap low-order byte and high order byte in an integer without using temporary variable?Q5 If we develop a project in C, then how can we create an .exe file of it?Q6 how to print 1 to 100
please let me know the answers to my email address as i having the interview in TCS so please please please please let me know  
Read Answers (12) | Asked by : M.srilatha

Char str[]="DOLLAR";Here , you have the base address of array i.e. str.By using only one pointer variable, you have to replace the occurrence of 'L' with '$$'. (after replacement, it should be DO$$$$AR)can any body suggest efficient method?
Read Answers (2) | Asked by : pavan kumar reddy
Tags : Pointer

Latest Answer : No ,its not possible to have a dynamic array without using calloc,malloc or without ptr.... Why u want to know abt it? but u can achieve a array without specifying size say arr[]; but its not efficient as when u use this array..more space will ...
Tags : Pointer

Latest Answer : #include#includevoid main(){ int a,i;clrscr();printf( " enter the number");scanf("%d",&a);for(i=a;i

Latest Answer : Here is the code for palindrome with recursive mechanism#includeint rev=0; //Global Variableint REV(int num){if(num>0){ rev=(rev*10)+ (num %10); REV(num / 10); //calling the Function recursively.         ...
Read Answers (1) | Asked by : alok kumar

it is an array representation i think 
View Question | Asked by : Venkatesh

Latest Answer : #include#includevoid main(){int x,y,z;clrscr();printf("enter the number");scanf("%d",&x);while(x>0){y=x%10;printf("%d",y);x=x/10;}getch();} ...
Read Answers (1) | Asked by : mcamuthu

View Question | Asked by : macgeek19


 Sponsored Links

 
Related Articles

Concepts of Object-Oriented Programming

Object Oriented JavaScript In this chapter you ll learn about OOP Object Oriented Programming and how it relates to JavaScript As an ASP NET developer you probably have some experience working with objects and you may even be familiar with concepts such as inheritance However unless you re already a
 

SQL Programming

SQL Programming Overview Anybody who has done something for a long time has probably wanted to change how things work at some point or another. A worker at a mill might have found a more efficient way of cutting logs, or a mathematics teacher might have had a hand in changing a school&rsquo;s al
 

Finding a New Job as a Senior

The days when almost everyone safely retired between 60 and 65 and went on to safely live off their pensions and social security are over. Over 60 percent of retirement-age employees are currently continuing to work full or part time, and 15 percent of the American workforce is currently over the ag
 

WinRunner Programming Concepts

If you want to create WinRunner scripts that are highly efficient, there are important programming concepts that you will want to become familiar with. Understanding these concepts will provide you with a large number of key benefits. In addition to understanding these concepts, you must also learn
 

Finding Your First Job Researching Jobs

by ResumeEdge.com - The Premier Resume Writing and Editing Service Now that determined your interests and skills, time to do some heavy-duty research on occupations. Now that determined your interests and skills, time to do some heavy-duty research. lose sight of the fact that your ability t
 

Programming Languages Certification

IT Certification programs have several options that will offer you the best knowledge.&nbsp; By learning everything that you need to know about information technology you will be able to open new doors to your career and personal business desires.&nbsp; IT Certification offers several vari
 

JavaScript Array Operations

JavaScript Array Operations In this JavaScript tutorial you will learn about different operations with array in JavaScript how to use the for in statement Combining Operations between arrays and within elements of an array joining two or more arrays and joining elements of an arrays along with synta
 

JavaScript Array Object Methods – Part II

JavaScript Array Object Methods Part II In this JavaScript tutorial you will learn about on array object methods slice splice toString shift and unshift methods along with general syntax and examples mosgoogle center slice By using the methods of the array object the programmer is able to retriev
 

JavaScript Array Object Methods – Part I

JavaScript Array Object Methods Part I In this JavaScript tutorial you will learn about Array Object Methods concat join pop push and reverse methods&nbsp; along with general syntax and examples mosgoogle center concat The concat method is used to join two or more Array objects together to pro
 

Neuro-linguistic Programming Methods

Neuro linguistic Programming Methods There are several methods used for performing Neuro linguistic Programming on an individual for obtaining insights into the psyche of the person in order to correct to modify certain patterns of behavior These techniques are also used for Neuro linguistic trainin
 

Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape