program to find a smallest number in an array

Answers were Sorted based on User's Feedback



program to find a smallest number in an array..

Answer / sathish

main()
{
int a[20],n,i,s;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
s=a[0];
for(i=0;i<n;i++)
{
if(s>a[i])
{
s=a[i];
}
}
printf("the smallest number is %d",s);
}

Is This Answer Correct ?    138 Yes 57 No

program to find a smallest number in an array..

Answer / 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

program to find a smallest number in an array..

Answer / .::get lost::.

#include<stdio.h>
#include<conio.h>

void main()
{
int a[20],n,i,s;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
s=a[0];
for(i=0;i<n;i++)
{
if(s>a[i])
{
s=a[i];
}
}
printf("the smallest number is %d",s);
getch();
}

Is This Answer Correct ?    24 Yes 10 No

program to find a smallest number in an array..

Answer / rose

#include<stdio.h>
#include<conio.h>
void main()
{
int n,a[50],temp;
printf("enter the max limit :");
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
i=0;
for(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 ?    19 Yes 15 No

program to find a smallest number in an array..

Answer / anu

#include<iostream.h>
#include<conio.h>
void main()
{
int a[20],n,i,s;
clrscr();
cout<<"Enter valur of n";
cin>>n;
cout<<"Enter the elements";
for(i=0;i<n;i++)
{
cin>>a[i];
}
s=a[0];
for(i=0;i<n;i++)
{
if(s>a[i])
{
s=a[i];
}
}
cout<<"The smallest number is"<<s
getch();
}

Is This Answer Correct ?    10 Yes 7 No

program to find a smallest number in an array..

Answer / asif ali afsar

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],b,c,n;
clrscr();
printf("How many size you want to Cheah\n");
scanf("%d",&n);
printf("Enter the numbers\n");
for(b=0; b<n; b++)
{
scanf("%d",&a[b]);
}
for(b=0; b<n; b++)
{
if(c<a[b])
{
c=c;
}
else
{
c=a[b];
}
}
printf("smalest no is %d",c);
getch();
}

Is This Answer Correct ?    3 Yes 1 No

program to find a smallest number in an array..

Answer / farhana parvin sunny

#include<stdio.h>
#include<conio.h>

int main(void)
{
int n,i,l,a[10];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
l=a[0];
for(i=0;i<n;i++)
{
if(l>a[i])
{
l=a[i];
}
}
printf("the lowest number is %d",l);
getch();
return 0;
}

Is This Answer Correct ?    2 Yes 0 No

program to find a smallest number in an array..

Answer / azhar shaik

int n, i,small,a[30];
clrscr();
pf("enter the no.of elements in an array");
sf("%d",&n);
pf("enter the elements \n");
for(i=0;i<n;i++)
{
pf("a[%d]= ,"i);
sf("%d\n",&ai[i]);
}
pf(" displaty the array elements ");
for(i=0;i<n;i++)
{
pf("%d\t",a[i]);
}
pf("smallest element from an array "):
small=a[0];
for(i=1;i<n;i++)
{
if(small>a[i])
{
small=a[i];
}
pf("smallest element is %d ",small);
getch();
}


hint:pf =print f ,sf =scan f

Is This Answer Correct ?    0 Yes 0 No

program to find a smallest number in an array..

Answer / subash

&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;

Is This Answer Correct ?    0 Yes 0 No

program to find a smallest number in an array..

Answer / belsia

void main()
{
int a[10];
for(i=0;i<10;i++)
scanf("%d",&a[i]);
for(i=0;i<10;i++)
{
if(a[i]>a[i+1])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
printf("The smallest element is %d",a[0]);
getch();
}

Is This Answer Correct ?    26 Yes 28 No

Post New Answer

More C Interview Questions

Sir,please help me out with the code of this question. Write an interactive C program that will encode or decode multiple lines of text. Store the encoded text within a data file, so that it can be retrieved and decoded at any time. The program should include the following features: (a) Enter text from the keyboard, encode the text and store the encoded text in a data file. (b) Retrieve the encoded text and display it in its encoded form. (c) Retrieve the encoded text, decode it and then display the decoded text. (d) End the computation. Test the program using several lines of text of your choice.

0 Answers  


Explain modulus operator.

0 Answers  


Difference between for loop and while loop?

1 Answers  


What is the purpose of main( ) in c language?

0 Answers  


How to removing white spces in c programming only bu using loops

2 Answers  






plz let me know how to become a telecom protocol tester. thank you.

0 Answers  


What is a node in c?

0 Answers  


Explain how do I determine whether a character is numeric, alphabetic, and so on?

0 Answers  


plz answer.. a program that takes a string e.g. "345" and returns integer 345

4 Answers  


How do you view the path?

0 Answers  


In C program, at end of the program we will give as "return 0" and "return 1", what they indicate? Is it mandatory to specify them?

5 Answers  


What is an expression?

0 Answers  


Categories