This code is an implementation of inserting an element in an array at a specific position. Here's how it works:
#include<iostream> using namespace std; int main() { cout<<"\n Welcome"; int i,t,a[10],n,s,j=0,b[10]; cout<<"\nEnter the Limit:"; cin>>n; cout<<"\nEnter the values:"; for(i=0;i<n;i++) { cin>>a[i]; } cout<<"\nGiven values are:"; for(i=0;i<n;i++) { cout<<"a["<<i<<"]="<<a[i]; } cout<<"\nEnter the position to be changed:"; cin>>t; cout<<"\nEnter the value to be changed:"; cin>>s; for(i=0;i<t;i++) { b[j]=a[i]; j++; } b[j]=s; j++; for(i=t;i<n;i++) { b[j]=a[i]; j++; } cout<<"\nInserted value is:"; for(i=0;i<=n;i++) { cout<<"\n"<<a[i]<<"="<<b[i]; } return 0; }To download raw file Click Here
Welcome Enter the Limit:4 Enter the values:1 2 3 4 Given values are:a[0]=1a[1]=2a[2]=3a[3]=4 Enter the position to be changed:2 Enter the value to be changed:2 Inserted value is: 1=1 2=2 3=2 4=3 1907379984=4
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions