Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,179 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,998 people online right now. Registration is fast and FREE... Join Now!




C programming

 
Reply to this topicStart new topic

C programming, how to find biggest and smallest number among n numbers

maga
2 Aug, 2007 - 11:19 PM
Post #1

New D.I.C Head
*

Joined: 2 Aug, 2007
Posts: 1


My Contributions
how to find biggest number among given n numbers in C programming
User is offlineProfile CardPM
+Quote Post

k.sangeeth
RE: C Programming
3 Aug, 2007 - 12:38 AM
Post #2

D.I.C Head
**

Joined: 27 Jul, 2007
Posts: 61


My Contributions
QUOTE(maga @ 3 Aug, 2007 - 12:19 AM) *

how to find biggest number among given n numbers in C programming


CODE

a[10]={3,4,5,1,8,9,1,6,7,8}
int temp,i;
temp=a[0]
for(i=1;i<10;i++)
{
   if(a[i]>temp)
      temp =a[i];

}
//temp is the largest number



similar thing for smallest number
User is offlineProfile CardPM
+Quote Post

Xing
RE: C Programming
3 Aug, 2007 - 08:00 AM
Post #3

D.I.C Addict
Group Icon

Joined: 22 Jul, 2006
Posts: 723



Thanked: 2 times
Dream Kudos: 1575
My Contributions
You can make use of std::max() algorithm of standard library.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 01:02AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month