Computer Science, asked by sanjay041074, 9 months ago

write a program to find the smallest digit of an integer that is input​

Answers

Answered by hakeemshah7707
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 AbhijithPrakash
13
  1. def smallest_no(a):  ## Defining the function for finding the smallest number.
  2.    n=[] ## First create a blank List.
  3.    for i in range(0,a):  ## for loop for inserting the numbers in a list and then sorting it.
  4.        n.insert(i,i) ## I'm using insert parameter. insert(index, element)
  5.        n[i]=int(input("Enter the {} number : ".format(i+1))) ## Collecting the numbers from the user.
  6.        N=sorted(n) ## sorted parameter to sort the list in ascending order.
  7.    print("The smallest number is {}.".format(N[0])) ## This will print the first number of the list.
  8.    ## End of the function.
  9. 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.
  10. smallest_no(a) ## Calling the function.
Attachments:
Similar questions