program to find a smallest number in an array
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
Describe the difference between = and == symbols in c programming?
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?
When should I declare a function?
printf("%d",(printf("Hello")); What it returns?
What is main return c?
Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
What are the types of macro formats?
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
why do some people write if(0 == x) instead of if(x == 0)?
When should we use pointers in a c program?