🔒 Closed Pa check po Ng sagut ko

Status
Not open for further replies.

If Else

Eternal Poster
create and array size with size of 5 and insert any number item into endex 4
main() {
Int LA[]=1,2,3,4,5
int item=5 k=2 n=5
Int i= 0,j=k


printf("The original array elements are :\);
for(i = 0; i<n; i++) {
printf("Array[%d] = %d \, i, Array); }
n = n + 1;
while( j >= k) {
Array[j+1] = Array[j];
j = j - 1; }
Array[k] = item;
printf("The array elements after insertion :\);
for(i = 0; i<n; i++) {
printf("Array[%d] = %d \, i, Array);

}}
 
C:
#include <stdio.h>

int main()
{
    int array[] = {5, 10, 15, 20, 25};
   
    printf("Original Array\n");
   
    for(int i = 0; i < 5; i++)
        printf("%d, ", array[i]);
       
      printf("\n");

    //insert any number to index index 4
    array[4] = 100;
   
    printf("New Array\n");
   
    for(int i = 0; i < 5; i++)
        printf("%d, ", array[i]);

    return 0;
}
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 3
    Replies
  • 444
    Views
  • 2
    Participants
Last reply from:
Arcturus

Trending Topics

Online now

Members online
357
Guests online
1,279
Total visitors
1,636

Forum statistics

Threads
2,292,900
Posts
29,080,055
Members
1,209,577
Latest member
yasssx67
Back
Top