bsc

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

root / semester_1 / letusc / luc059.c

luc059.c (852B)


      1 /* Write a program which initializes an integer array of 10 elements in main(), passes it to modify(), multiplies each element by 3, and prints the new array in main().
      2 */
      3 
      4 /* Let Us C, Chap- 13 (Arrays), Qn No.: B(e) */
      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 void modify(int *, int);
     15 
     16 int main()
     17 {
     18     int arr[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
     19     int i;
     20 
     21     printf("Original Array:\n");
     22     for (i = 0; i < 10; i++)
     23         printf("%d ", arr[i]);
     24     
     25     modify(arr, 10);
     26 
     27     printf("\n\nModified Array (x3):\n");
     28     for (i = 0; i < 10; i++)
     29         printf("%d ", arr[i]);
     30     printf("\n");
     31 
     32     return 0;
     33 }
     34 
     35 void modify(int *a, int n)
     36 {
     37     int i;
     38     for (i = 0; i < n; i++)
     39     {
     40         a[i] = a[i] * 3;
     41     }
     42 }
© 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