Simple C Program with Algorithm, Flowchart, Output - Computer Programming - C
Write a program to
insert an element into an array in a specified position.
AIM
To
write a program to insert an element to array.
ALGORITHM
Step‒1:
Start
Step-2 :
Read input to n
Step-3 :
Read n elements using loop
Step-4 :
Read item to be insert
Step-5 :
Read position there to insert
Step-6 :
Increment n by 1
Step-7 :
Setup loop k from n to k >= pos
Step-8 :
Assign a[k‒1] to a[k]
Step-9 :
Assign item to a[‒‒pos]
Step-10 :
Print array elements using loop
Step‒11 :
Stop
FLOWCHART

PROGRAM
#include<stdio.h>
void main()
{
int i,j,k,n,pos; float a[50],item;
printf("Enter the last value: ");
scanf("%d",&n);
printf("Enter the elements of array: \n");
for(i=0;i<n;i++)
scanf("%f",&a[i]);
printf("Enter element to be inserted :");
scanf("%f",&item);
printf("Enter position of insertion :" );
scanf("%d",&pos);
n++;
for(k=n;k>=pos;k‒)
a[k]=a[k‒1];
a[‒pos]=item;
printf("Elements after insertion is: \n");
for(i=0;i<n;i++)
printf("%.2f",a[i]);
printf("\n");
}
OUTPUT
Enter the last value:
5
Enter the elements of
array:
12 34 56 90 32
Enter element to be
inserted: 36
Enter position of
insertion: 4
Elements after
insertion is:
12.00 34.00 56.00
36.00 90.00 32.00
Computer Programming C Laboratory: Practical C Programs : Tag: C Programming : C Program with Algorithm, Flowchart, Output - Write a C program to insert an element into an array in a specified position
Computer Programming C
CS25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Computer Programming C Laboratory
CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
English Essentials I
EN25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
தமிழர் மரபு - Heritage of Tamils
UC25H01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Applied Calculus
MA25C01 Maths 1 M1 - 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Applied Physics I
PH25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Applied Chemistry I
CY25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Makerspace
ME25C04 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Computer Programming C
CS25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Computer Programming Python
CS25C02 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Fundamentals of Electrical and Electronics Engineering
EE25C03 1st Semester EEE Depart | 2025 Regulation | 1st Semester 2025 Regulation
Introduction to Mechanical Engineering
ME25C03 1st Semester Mechanical Dept | 2025 Regulation | 1st Semester 2025 Regulation
Introduction to Civil Engineering
CE25C01 1st Semester Civil, Agri Departments | 2025 Regulation | 1st Semester 2025 Regulation
Essentials of Computing
CS25C03 1st Semester - AIDS, CSE, CSE(CY), IT Department | 2025 Regulation | 1st Semester 2025 Regulation
Applied Physics I Laboratory
PH25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Applied Chemistry I Laboratory
CY25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Computer Programming C Laboratory
CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Computer Programming Python Laboratory
CS25C02 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Engineering Drawing
ME25C01 EEE, Mech, Agri, EEE Depts | 2025 Regulation | 2nd Semester 2025 Regulation
Basic Electronics and Electrical Engineering
EE25C04 1st Semester ECE Dept | 2025 Regulation | 1st Semester 2025 Regulation
Essentials of Computing - Laboratory
CS25C03 1st Semester AIDS, CSE, CSE(CY), IT Depts | practical Laboratory Manual | 2025 Regulation | 1st Semester 2025 Regulation