0% found this document useful (0 votes)
36 views

10-11 Oops

The document describes two experiments involving arrays and pointers in C++. The first experiment involves writing a program to add elements in an array using pointers. The second experiment involves writing a program to compare elements of two arrays using pointers. Both experiments aim to understand the concepts of arrays and pointers. The source code and outputs are provided for each experiment.

Uploaded by

Anurag Gupta
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)
36 views

10-11 Oops

The document describes two experiments involving arrays and pointers in C++. The first experiment involves writing a program to add elements in an array using pointers. The second experiment involves writing a program to compare elements of two arrays using pointers. Both experiments aim to understand the concepts of arrays and pointers. The source code and outputs are provided for each experiment.

Uploaded by

Anurag Gupta
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/ 4

Experiment -10

Title of experiment:- Write a program to add elements in array using pointers.


Aim of experiment:- To understand concept of array and pointers.
Source code:-
#include<iostream>
using namespace std;
#include<conio.h>
int main()
{
int s,i,j;
int a[10];
s=0;
cout<<"enter any 10 values:- "<<endl;
for(i=0;i<10;i++)
{
cin>>a[i];
}
for(j=0;j<10;j++)
{
s=s+ *(a+j);
}
cout<<"sum of array:- "<<s<<endl;
getch();
return 0;
}

1703233 Anurag
Output:-

1703233 Anurag
Experiment -11
Title of experiment:- Write a program to compare elements of 2 arrays using pointers.
Aim of experiment:- To understand concept of array and pointers.
Source code:-

#include<iostream>
using namespace std;
#include<conio.h>
int main()
{
int i,j,c,r=0;
int a[5],b[5];
for(i=0;i<5;i++)
{
cout<<"enter value of a"<<endl;
cin>>a[i];
}
for(j=0;j<5;j++)
{
cout<<"enter value of b"<<endl;
cin>>b[j];
}
for (c=0;c<5;c++)
{
if(*(a+c) == *(b+c))
{
r=r+1;
continue;
}
}
if (r==5)
{
cout<<"array are equal";
}
else
{
cout<<"array are not equal";
}
getch();
return 0;
}

1703233 Anurag
Output:-

Case-1 (When arrays are not equal)

Case-2(When array are equal)

1703233 Anurag

You might also like