program to find a smallest number in an array

Answer Posted / vignesh1988i

i think this logic would work out...

#include<stdio.h>
#include<conio.h>
void main()
{
int n,a[50],temp;
printf("enter the max limit :");
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
i=0;
for(int j=0;j<n-1;j++)
{
if(a[j+1]<a[j])
{
temp=a[j+1];
a[j+1]=a[j];
a[j]=temp;
}
}
printf("the smnallest is : %d",*(a+0));
getch();
}

Is This Answer Correct ?    59 Yes 30 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the 5 types of organizational structures?

546


When can a far pointer be used?

584


What are the complete rules for header file searching?

664


What is cohesion and coupling in c?

587


Given a valid 24 hour format time find the combination of the value and write a program ,do not hard the value and if any other inputs provided should work with the logic implemented Input: 11:30 Output: 13:10 Input: 18:25 Output: 21:58

1115






How do you override a defined macro?

693


p*=(++q)++*--p when p=q=1 while(q<=6)

1264


Write the test cases for checking a variable having value in range -10.0 to +10.0?

1813


Can the curly brackets { } be used to enclose a single line of code?

709


 write a program that will open the file, count the number of occurences of each word in the the complete works of shakespeare.  You will then tabulate this information in another file.

1722


What is pointer & why it is used?

598


What is d'n in c?

624


What is "Duff's Device"?

697


What is variable in c example?

590


program to convert a integer to string in c language'

1980