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

main()
{
int a[20],n,i,s;
scanf("%d,%d",&n,&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 ?    5 Yes 7 No

program to find a smallest number in an array..

Answer / fg

vcxcx

Is This Answer Correct ?    0 Yes 2 No

program to find a smallest number in an array..

Answer / kalee

// Algorithm

Add the numbers directly into a set<double> varible, while getting the values from keyboard. First element of this set will be the least integer

This is a bad answer , if memory constraint is to be taken into account

Is This Answer Correct ?    4 Yes 9 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[i+1];
a[i+1]=temp;
}
}
printf("The smallest element is %d",a[0]);
getch();
}

Is This Answer Correct ?    7 Yes 17 No

program to find a smallest number in an array..

Answer / atul kumar

#include<iostream.h>
void main()
{
int a, b[4]=[1,2,3,4];
a[0]=b[0];
for(i=1;i<=5;i++)
{
if(a>b[i])
{
a=b[i];
}
}
cout<<"smallest num"<<a;
}

Is This Answer Correct ?    7 Yes 18 No

Post New Answer

More C Interview Questions

Describe the difference between = and == symbols in c programming?

0 Answers  


macros and function are related in what aspect? a)recursion b)varying no of arguments c)hypochecking d)type declaration

12 Answers   HCL, Infosys, Microsoft,


How to access or modify the const variable in c ?

16 Answers   HCL, HP,


How can I read and write comma-delimited text?

0 Answers  


When should I declare a function?

0 Answers  






printf("%d",(printf("Hello")); What it returns?

32 Answers   TCS,


What is main return c?

0 Answers  


Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

0 Answers  


What are the types of macro formats?

0 Answers  


what will the following program do? void main() { int i; char a[]="String"; char *p="New Sring"; char *Temp; Temp=a; a=malloc(strlen(p) + 1); strcpy(a,p); //Line no:9// p = malloc(strlen(Temp) + 1); strcpy(p,Temp); printf("(%s, %s)",a,p); free(p); free(a); } //Line no 15// a) Swap contents of p & a and print:(New string, string) b) Generate compilation error in line number 8 c) Generate compilation error in line number 5 d) Generate compilation error in line number 7 e) Generate compilation error in line number 1

1 Answers   IBM,


why do some people write if(0 == x) instead of if(x == 0)?

0 Answers  


When should we use pointers in a c program?

0 Answers  


Categories