Advertisement
Marufcse

Insert At the beginnig of The Arrau

Dec 20th, 2021
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.    int array[100], position, c, n, value;
  6.    printf("Enter number of elements in array\n");
  7.    scanf("%d", &n);
  8.  
  9.    printf("Enter %d elements\n", n);
  10.  
  11.    for (c = 0; c < n; c++)
  12.       scanf("%d", &array[c]);
  13.  
  14.  
  15.    printf("Enter the value to insert\n");
  16.    scanf("%d", &value);
  17.  
  18.    for (c = n - 1; c >= 0 - 1; c--)
  19.       array[c+1] = array[c];
  20.  
  21.    array[0] = value;
  22.  
  23.    printf("Resultant array is\n");
  24.  
  25.    for (c = 0; c <= n; c++)
  26.       printf("%d\n", array[c]);
  27.  
  28.    return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement