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
What are the 5 types of organizational structures?
When can a far pointer be used?
What are the complete rules for header file searching?
What is cohesion and coupling in c?
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
How do you override a defined macro?
p*=(++q)++*--p when p=q=1 while(q<=6)
Write the test cases for checking a variable having value in range -10.0 to +10.0?
Can the curly brackets { } be used to enclose a single line of code?
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.
What is pointer & why it is used?
What is d'n in c?
What is "Duff's Device"?
What is variable in c example?
program to convert a integer to string in c language'