Inserting an element in an array (C program)

preview_player
Показать описание
Follow my Whatsapp channel for content updates, questions, contests and many more...

Technical lectures by Shravan Kumar Manthri.
Watch " Patterns in C- Tips & Tricks " in the following link...

You can watch "Tricky 150 mcqs in C" in the following link

Technical lectures by Shravan Kumar Manthri.
Watch Technical C programming

Watch Data Warehousing & Data Mining

Watch Design & Analysis of Algorithms

Watch Formal Languages & Automata theory

Like us on fb: CSE GURUS

This video Inserting an element in an array with execution. #ShravankumarManthri#CSEGURUS #ShravankumarManthri#CSEGURUS
Рекомендации по теме
Комментарии
Автор

Sir y we should decrement here we need to increment right

Mamathahomemadepowder
Автор

Very nice Thank you so You solved my problem.... Thank you again ❤

dipeshchoudhary
Автор

Sir if i want to do while loop then how can i do, i try lot but i dont understand how to do ?

priyankapaul
Автор

= in last for loop is giving garbage value i think it shouldn't be there?

divyanshpandey
Автор

Thank you so much
Great explanation sir, God bless you

gayathrisabbella
Автор

but last value is not printing becz length is not can we do that ??

arunsharma
Автор

suggest any compiler for cprogramming language.

champianbro
Автор

A little correction:
array[position] = value ;

nusrat
Автор

The second last for loop is wrong!!!There you have to take i>=position-1.

a-classzone
Автор

Why we cant insert like this temp=array[position]
array[position]=element
array[size]=temp..


Pls rply sir...

ilhjqhh
Автор

You should do code for it pn your computer screen

bhavikbansiwal
Автор

why we need to take (pos-1) if we want to put the value in the index 3 we can directly give for(int i=0;i>=pos;i--)

rajeshkumar-gfwe
Автор

#include <stdio.h>

int main()
{
int array[50], position, c, n, value;

printf("Enter number of elements in the array\n");
scanf("%d", &n);

printf("Enter %d elements\n", n);

for (c = 0; c < n; c++)
scanf("%d", &array[c]);

printf("Please enter the location where you want to insert an new element\n");
scanf("%d", &position);

printf("Please enter the value\n");
scanf("%d", &value);

for (c = n - 1; c >= position - 1; c--)
array[c+1] = array[c];

array[position-1] = value;

printf("Resultant array is\n");

for (c = 0; c <= n; c++)
printf("%d\n", array[c]);

return 0;
}

SarafatAlamIrfan