write a program to find the smallest digit of an integer that is input
Answers
Answered by
3
Answer:
#include<stdio.h>
#include<conio.h>
void main()
{
int n,a[100],s,i;
printf("\nHow many numbers :");
scanf("%d",&n);
printf("Enter the integer numbers:");
for(i=0;i<n;i++)
{
scanf("%d",a[i]));
}
s=a[0];
for(i=0;i<n;i++)
{
if(a[i]<s){
s=a[i];
}
}
printf("smallest number is:%d",s);
getch(0);
}
Explanation:
Answered by
13
- def smallest_no(a): ## Defining the function for finding the smallest number.
- n=[] ## First create a blank List.
- for i in range(0,a): ## for loop for inserting the numbers in a list and then sorting it.
- n.insert(i,i) ## I'm using insert parameter. insert(index, element)
- n[i]=int(input("Enter the {} number : ".format(i+1))) ## Collecting the numbers from the user.
- N=sorted(n) ## sorted parameter to sort the list in ascending order.
- print("The smallest number is {}.".format(N[0])) ## This will print the first number of the list.
- ## End of the function.
- a=int(input("How many numbers do you want to enter : ")) ## Asking the user for the value of a, so that we can use it in the for loop.
- smallest_no(a) ## Calling the function.
Attachments:
Similar questions