0% found this document useful (0 votes)
3 views10 pages

Experiment 1 AIM:-Write A Program To Search An Element in An Array - Tools: - Online C++ Compiler, Windows, Desktop, Laptop, Internet. Program

The document contains a series of experiments demonstrating basic array operations in C++, including searching, traversing, updating, inserting, and deleting elements at various positions. Each experiment includes an aim, the necessary tools, and the corresponding C++ program code. Outputs are also indicated but not explicitly shown in the document.

Uploaded by

tanuvishu6699
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views10 pages

Experiment 1 AIM:-Write A Program To Search An Element in An Array - Tools: - Online C++ Compiler, Windows, Desktop, Laptop, Internet. Program

The document contains a series of experiments demonstrating basic array operations in C++, including searching, traversing, updating, inserting, and deleting elements at various positions. Each experiment includes an aim, the necessary tools, and the corresponding C++ program code. Outputs are also indicated but not explicitly shown in the document.

Uploaded by

tanuvishu6699
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

EXPERIMENT 1

AIM:- Write a program to search an element in an array .

Tools :- online c++ compiler, Windows, Desktop,Laptop,Internet.

Program:

#include<iostream>

using namespace std;

int main()

int a[100],n,i,x;

cout<<"\nEnter The Limit: ";

cin>>n;

for(i=0;i<n;i++)

cout<<"\nEnter The Value : ";

cin>>a[i];

cout<<"\nEnter The Value to Search :";

cin>>x;

for(i=0;i<n;i++)//1 2 3 4 5

if(a[i]==x)

cout<<"Value Found @"<<i;

return 0;

cout<<"Value Not Found";

return 0;

Output:
EXPERIMENT 2

AIM: - Write a program to traversing each element in an array .

Tools:- online c++ compiler, Windows, Desktop,Laptop,Internet.

Program:

#include <iostream>

using namespace std;

int main()

int arr[5]={10,2,20,0,30};

for (int i = 0; i < 5; i++)

cout<<arr[i]<<"\n";

Output;
EXPERIMENT 3

AIM: - Write a program to update element in an array .

Tools:- online c++ compiler, Windows, Desktop,Laptop,Internet.

Program:

#include <iostream>

int main() {

int numbers[] = {10, 20, 30, 40, 50};

numbers[2] = 35;

for (int i = 0; i < 5; i++) {

std::cout << numbers[i] << " ";

return 0;

Output:
EXPERIMENT 4(a)

AIM:- Write a program to insert an element in an array at the beginning position.

Tools :- online c++ compiler, Windows, Desktop,Laptop,Internet.

Program:

#include <iostream>

using namespace std;

int main() {

int arr[10] = {20, 30, 40, 50};

int size = 4;

int value = 10;

for (int i = size; i > 0; i--) {

arr[i] = arr[i - 1];

arr[0] = value;

size++;

for (int i = 0; i < size; i++) {

cout << arr[i] << " ";

return 0;

Output:
EXPERIMENT 4(b)

AIM:- Write a program to insert an element in an array at the middle position.

Tools :- online c++ compiler, Windows, Desktop,Laptop,Internet.

Program:-

#include <iostream>

using namespace std;

int main() {

int arr[10] = {10, 20, 40, 50};

int size = 4;

int value = 30;

int position = 2;

for (int i = size; i > position; i--) {

arr[i] = arr[i - 1];

arr[position] = value;

size++;

for (int i = 0; i < size; i++) {

cout << arr[i] << " ";

return 0;

Output:
EXPERIMENT 4(c)

AIM:- Write a program to insert an element in an array at the last position.

Tools :- online c++ compiler, Windows, Desktop,Laptop,Internet.

Program:

#include <iostream>

using namespace std;

int main() {

int arr[10] = {10, 20, 30, 40};

int size = 4;

int value = 50;

arr[size] = value;

size++;

for (int i = 0; i < size; i++) {

cout << arr[i] << " ";

return 0;

Output:
EXPERIMENT 5(a)

AIM:- Write a program to delete an element in an array at the first position.

Tools :- online c++ compiler, Windows, Desktop,Laptop,Internet.

Program:

#include <iostream>

using namespace std;

int main() {

int arr[10] = {10, 20, 30, 40, 50};

int size = 5;

for (int i = 0; i < size - 1; i++) {

arr[i] = arr[i + 1];

size--;

for (int i = 0; i < size; i++) {

cout << arr[i] << " ";

return 0;

Output:
EXPERIMENT 5(b)

AIM:- Write a program to delete an element in an array at the middle position.

Tools :- online c++ compiler, Windows, Desktop,Laptop,Internet.

Program:

#include <iostream>

using namespace std;

int main() {

int arr[10] = {10, 20, 30, 40, 50};

int size = 5;

int position = 2;

for (int i = position; i < size - 1; i++) {

arr[i] = arr[i + 1];

size--;

for (int i = 0; i < size; i++) {

cout << arr[i] << " ";

return 0;

Output:
EXPERIMENT 5(c)

AIM:- Write a program to delete an element in an array at the last position.

Tools :- online c++ compiler, Windows, Desktop,Laptop,Internet.

Program:

#include <iostream>

using namespace std;

int main() {

int arr[10] = {10, 20, 30, 40, 50};

int size = 5;

size--;

for (int i = 0; i < size; i++) {

cout << arr[i] << " ";

return 0;

Output:

You might also like