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
Explain what is the benefit of using #define to declare a constant?
In C programming, how do you insert quote characters (‘ and “) into the output screen?
What are the 5 types of inheritance in c ++?
What is the use of header?
Why void main is used in c?
How can a string be converted to a number?
What language is windows 1.0 written?
Calculate 1*2*3*____*n using recursive function??
Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?
What is quick sort in c?
Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.
Define recursion in c.
What are the scope of static variables?
Write a program to reverse a given number in c language?
Which driver is a pure java driver