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 modulus operator. What are the restrictions of a modulus operator?
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].
What is a class c rental property?
typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none
Explain what does the function toupper() do?
we called a function and passed something do it we have always passed the "values" of variables to the called function. such functions calles are called a) calls by reference b) calls by value c) calls by zero d) none of the above
What are the types of pointers?
What is a macro in c preprocessor?
Write a code to remove duplicates in a string.
Describe how arrays can be passed to a user defined function
What is a string?
What happens if a header file is included twice?
How do you write a program which produces its own source code as output?
What is #line?
What is the size of enum in bytes?