WRITE a C program to find the smallest number in a given list of 10 numbers.also…
- User
WRITE a C program to find the smallest number in a given list of 10 numbers.also ,calculate and display the number of times the loop statement was executed.
- Assistant
Here is the C program to find the smallest number in a given list of 10 numbers and calculate the number of times the loop statement was executed:
c#include <stdio.h> int main() { int numbers[10]; int smallest, count = 0; printf("Enter 10 numbers: \n"); // Reading the numbers from the user for(int i = 0; i < 10; i++) { scanf("%d", &numbers[i]); } // Initializing smallest with the first number smallest = numbers[0]; // Finding the smallest number for(int i = 1; i < 10; i++) { // Counting the number of loop executions count++; if(numbers[i] < smallest) { smallest = numbers[i]; } } printf("The smallest number is: %d\n", smallest); printf("The loop statement was executed %d times.\n", count); return 0; }