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

Is file a keyword in c?

505


Explain is it better to bitshift a value than to multiply by 2?

720


4-Take two sets of 5 numbers from user in two arrays. Sort array 1 in ascending and array 2 in descending order. Perform sorting by passing array to a function mySort(array, sortingOrder). Then multiply both the arrays returned from function, using metric multiplication technique in main. Print result in metric format.

1731


write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.

1580


Explain how can I pad a string to a known length?

658






What are operators in c?

586


What is the difference between #include and #include 'file' ?

610


How do you initialize pointer variables?

616


What is operator precedence?

647


Do you know what are the properties of union in c?

588


Why is c so important?

598


What is a substring in c?

590


What are the advantages of external class?

598


Is c is a procedural language?

601


What are high level languages like C and FORTRAN also known as?

689