jituTechnology

jituTechnology

A program to find the smallest element in an array using pointer.

A program to find the smallest element in an array using pointer.

Codes
/*A program to find the smallest element in an array using pointer*/
/*Programed by          Jitendra Kr Yadav
                        10116
                        2Apr,2011*/
#include<stdio.h>
#include<conio.h>
void smallest(int, int*);
main()
{
intn,a[20];
printf(“Enter the no of input to be taken:”);
scanf(“%d”,&n);
printf(“Enter the input:\n”);
for(int i=0;i<n;i++)
scanf(“%d”,&a[i]);
smallest(n,&a[0]);
printf(“Minimum =%d\n\n”,a[n-1]);
printf(“Press any key to continue…”);
getch();
}
void smallest(intx,int*num)
{
inti,temp;
for(i=0;i<x-1;i++)
if(num[i]<num[i+1])
{
temp=num[i];
num[i]=num[i+1];
num[i+1]=temp;
}
}
Output
Enter the no of input to be taken: 5
Enter the number:
6
2
9
4
0
Minimum = 0
Press any key to continue…

 

Add a comment

Comments (1)

  1. Loyd HusethApril 6, 2012 Reply
    Hi it’s me Fiona, I am also visiting this website on a regular basis, this web page is actually nice and the people are genuinely sharing fastidious thoughts.

Add a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Connect with Me

GPO 8973 NPC 541; Kathmandu Nepal
Phone: +977 9851236800

Calendar

March 2019
S M T W T F S
« Jun    
 12
3456789
10111213141516
17181920212223
24252627282930
31