- #1
sg001
- 134
- 0
Homework Statement
I am writing a program so that a user can input up to ten integers and then sought through and print the smallest from that input
i.e. enter in up to ten integers: "7 5 6 19 4 8"
the smallest number is 4
Homework Equations
The Attempt at a Solution
Here's my attempt so far but I am getting compiling errors
min.c:5: warning: return type of ‘main’ is not ‘int’
min.c: In function ‘main’:
min.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
min.c:21: error: expected ‘{’ at end of input
but apart fro that I think my code is missing something but I don't know what
any help would be great.
code::
#include <stdio.h>
#define MAX 10
int main(int argc, char * argv[]){
int i,small;
int num[MAX];
printf("Enter up to %d integers:\n",MAX);
i=0;
scanf("%d", &num);
for(i=1;i<num;i++){
if(num<small){
small=num;
}
}
printf("The smallest element in the array is %d\n", small);
return 0;
}