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
Is file a keyword in c?
Explain is it better to bitshift a value than to multiply by 2?
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.
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.
Explain how can I pad a string to a known length?
What are operators in c?
What is the difference between #include and #include 'file' ?
How do you initialize pointer variables?
What is operator precedence?
Do you know what are the properties of union in c?
Why is c so important?
What is a substring in c?
What are the advantages of external class?
Is c is a procedural language?
What are high level languages like C and FORTRAN also known as?