bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / letusc / luc057.c

luc057.c (784B)


      1 /* Write a program using pointers to find the smallest number in an array of 25 integers.
      2 */
      3 
      4 /* Let Us C, Chap- 13 (Arrays), Qn No.: B(c) */
      5 
      6 /* This file is auto-generated by a bot. */
      7 /* This code is not compiled; it is for reference only. */
      8 
      9 
     10 #include <stdio.h>
     11 #include <math.h>
     12 #include <stdlib.h>
     13 
     14 int main()
     15 {
     16     int arr[25], i, min;
     17     int *ptr;
     18 
     19     printf("Enter 25 integers:\n");
     20     for (i = 0; i < 25; i++)
     21     {
     22         scanf("%d", &arr[i]);
     23     }
     24 
     25     ptr = arr; // Point to start of array
     26     min = *ptr; // Initialize min with first element
     27 
     28     for (i = 1; i < 25; i++)
     29     {
     30         ptr++; // Move pointer to next element
     31         if (*ptr < min)
     32         {
     33             min = *ptr;
     34         }
     35     }
     36 
     37     printf("\nSmallest number is: %d\n", min);
     38 
     39     return 0;
     40 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror