Blog Moved

This website completely moved to new domain. For latest content, visit www.programmingposts.com

Search This Blog

6 May 2013

C PROGRAM TO FIND LARGEST AND SMALLEST NUMBER IN AN ARRAY

C PROGRAM TO FIND LARGEST AND SMALLEST NUMBER IN AN ARRAY

#include<stdio.h>
#define MAX 25 //maximum size of array is 25

main()
{
  int i,n,LargeNo,SmallNo,arr[MAX];

  printf(" *** C PROGRAMS BLOG ***");
  printf("\n >>> Program to find Largest element in array <<<");
  printf("\n\n Enter the size of array: ");
  scanf("%d",&n); //taking size of array as input from user
  printf("\n Enter the %d elements of array: \n",n);
  
  //taking input all the elements of array using for loop
  for(i=0;i<n;i++)
  {
   printf("\n arr[%d]:",i+1);
   scanf("%d",&arr[i]);    
  }
   LargeNo = arr[0];
   SmallNo = arr[0];
   for(i=0;i<n;i++)
   {
    //checking for Largest Number
    if(arr[i]>LargeNo)
    {
     LargeNo = arr[i];
    }
    //checking for Smallest Number
    if(arr[i]<SmallNo)
    {
     SmallNo = arr[i];
    }
   }
  //printing the largest and Smallst elements in array
  printf("\n The Largest Element in the Array is: %d ",LargeNo);
  printf("\n The Smallest Element in the Array is: %d ",SmallNo);
  getch();
}

Sample Output :

29 comments:

  1. Good
    Here is a link for C/C++ programs and pointer programs. This may be useful for you.

    C/C++ Programs

    ReplyDelete
  2. This blog awesome and i learn a lot about programming from here.The best thing about this blog is that you doing from beginning to experts level.

    Love from

    ReplyDelete
    Replies
    1. This comment has been removed by a blog administrator.

      Delete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. how can made pascal triangle in c programming

    ReplyDelete
  5. This blog awesome and i learn a lot about programming from here.The best thing about this blog is that you doing from beginning to experts level.

    Love from

    ReplyDelete
  6. hi.its really awesome blog.thank you for sharing this blog.
    Salesforce Training

    ReplyDelete
  7. actually it was an awesome blog.thank you for sharing this.its really informative to me.
    C Programming Training

    ReplyDelete
  8. hi its really awesome blog.thank you for sharing this blog.
    C Programming Training

    ReplyDelete
  9. Very Informative! This blog is great source of information which is very useful for me. eCommerce Solution Provider India

    ReplyDelete
  10. really nice blog about c. c is the base for java. if you clear about c then learning of java is very simple to you. for best java training in chennai reach us at TIA academy

    ReplyDelete
  11. I have read your blog and i got a very useful and knowledgeable information from your blog.You have done a great job . If anyone want Java Training in Chennai, Please visit our page
    Java Training in Chennai

    ReplyDelete
  12. Very Useful information that i have found. don't stop sharing and Please keep updating us..... Thanks

    ReplyDelete
  13. I have read your blog very clearly. I got lot of useful information from this blog.You have good coding knowledge. keep sharing more blogs like this type of coading. Thanks for sharing.


    Software Testing Training in Chennai

    ReplyDelete
  14. Nice tutorial. Thanks for sharing the valuable info about c Training. it’s really helpful. Who want to learn c language this blog most helpful. Keep sharing on updated tutorials…..

    ReplyDelete
  15. This comment has been removed by the author.

    ReplyDelete
  16. Nice tutorial. to learn more c programming visit here.

    ReplyDelete
  17. Nice blog, thanks for sharing useful information.

    ReplyDelete
  18. Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital informationC Programming Training in Chennai

    ReplyDelete
  19. This information is impressive; I am inspired by your post writing style & how continuously you describe this topic.... Java Training in Chennai | Blue prism Training in Chennai

    ReplyDelete
  20. PemainBandarQ - Agen Poker dan Domino Terpercaya dan Terbesar se-Indonesia 100% no bot no admin

    Yuk bergabung bersama kami di PemainBandarQ!! Dengan 1 User ID
    Anda dapat akses ke 8 permainan terbaik se-Indonesia. Dengan Minimal DEPO&WD hanya Rp. 15.000,-. Anda bisa memenangkan sampai PULUHAN JUTA rupiah.

    Dengan 1 User ID anda bisa akses ke 8 permainan:
    *Poker
    *AduQ
    *DominoQQ
    *BandarQ
    *BandarPoker
    *BandarSakong
    *CapsaSusun
    *BANDAR66
    Nikmati juga bonus yang kami sediakan, diantaranya :
    -Bonus TurnOver Sebesar 0.5% Yang dibagikan Setiap Hari !!!
    -Bonus Referral Seumur Hidup sebesar 20%

    Untuk mempermudah transaksi member, Kami menyediakan 5 Bank Terbaik se- Indonesia : BCA, BNI, BRI, Mandiri, Danamon

    Yuk langsung aja daftarkan diri anda di :
    https://goo.gl/kafuCC

    Untuk info lebih lanjut silahkan kunjungi Customer Service kami di :
    LiveChat : https://goo.gl/P4fHDo
    PIN BBM : 2BF939F6
    SKYPE : PemainBandarQ
    Facebook : https://goo.gl/cukg3u
    Twitter : @Pemainbandarq

    ReplyDelete