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
Why & is used in scanf in c?
Can we add pointers together?
What the different types of arrays in c?
How are strings stored in c?
What are header files in c?
Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1
What is the difference between a free-standing and a hosted environment?
what is the significance of static storage class specifier?
hi any body pls give me company name interview conduct "c" language only
How can you determine the size of an allocated portion of memory?
How to explain the final year project as a fresher please answer with sample project
formula to convert 2500mmh2o into m3/hr
write a program in C that prompts the user for today's date,tomorrow's date and display the results.Use structures for today's date,tomorrow's date and an array to hold the days for each month of the year.
a number whose only prime factors are 2,3,5, and 7 is call humble number,,write a program to find and display the nth element in this sequence.. sample input : 2,3,4,11,12,13, and 100.. sample output : the 2nd humble number is 2,the 3rd humble number is 3,the 4th humble number is ,the 11th humble number is 12, the 12th humble number is 14, the 13th humble number is 15, the 100th humble number is 450.
Explain the red-black trees?