Answers:
Even though the entire array cannot be returned from a function, the pointer i.e. the starting address of an array can be returned.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[i],diff=0,n;
printf("enter the number of elements :");
scanf("%d",&n);
printf("enter the elements:");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<=n;i++)
{
diff=a[i]-diff;
printf("difference of the elements stored in an array :%d",diff);
}
}
output :
enter the number of elements : 3
enter the elements :
20
10
5
difference of the elements stored in an array :5
#include<stdio.h>
#include<conio.h>
void main()
{
int a[i],diff=0,n;
printf("enter the number of elements :");
scanf("%d",&n);
printf("enter the elements:");
scanf("%d",&a[i]);
for(i=0;i<=n;i++)
{
diff=a[i]-diff;
printf("difference of the elements stored in an array :%d",diff);
}
}
output :
enter the number of elements : 3
enter the elements :
20
10
5
difference of the elements stored in an array :5
#include<stdio.h>
#include<conio.h>
void main()
{
int a[i],diff=0,n;
printf("enter the number of elements :");
scanf("%d",&n);
printf("enter the elements:");
scanf("%d",&a[i]);
for(i=0;i<=n;i++)
{
diff=a[i]-diff;
printf("difference of the elements stored in an array :%d",diff);
}
}
output :
enter the number of elements : 3
enter the elements :
20
10
5
difference of the elements stored in an array :5
#include<stdio.h>
#include<conio.h>
void main()
{
int a[i],diff=0,n;
printf("enter the number of elements :");
scanf("%d",&n);
printf("enter the elements:");
scanf("%d",&a[i]);
for(i=0;i<=n;i++)
{
diff=a[i]-diff;
printf("difference of the elements stored in an array :%d",diff);
}
}
output :
enter the number of elements : 3
enter the elements :
20
10
5
difference of the elements stored in an array :5
#include<stdio.h>
#include<conio.h>
void main()
{
int a[i],diff=0,n;
printf("enter the number of elements");
scanf("%d",&n);
printf("enter the array elements");
for(i=0;i<=n;i++)
scanf("%d",&a[i]);
for(i=0;i<=n;i++)
diff=a[i]-diff;
printf("diff of the elements:%d",diff);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a[i],diff=0,n;
printf("enter the number of elements :");
scanf("%d",&n);
printf("enter the elements:");
scanf("%d",&a[i]);
for(i=0;i<=n;i++)
{
diff=a[i]-diff;
printf("difference of the elements stored in an array :%d",diff);
}
}
output :
enter the number of elements : 3
enter the elements :
20
10
5
difference of the elements stored in an array :5
#include<stdio.h>
#include<conio.h>
void main()
{
int a[i],diff=0,n;
printf("enter the number of elements :");
scanf("%d",&n);
printf("enter the elements:");
scanf("%d",&a[i]);
for(i=0;i<=n;i++)
{
diff=a[i]-diff;
printf("difference of the elements stored in an array :%d",diff);
}
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a[i],diff=0,n;
printf("enter the number of elements :");
scanf("%d",&n);
printf("enter the elements:");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<=n;i++)
{
diff=a[i]-diff;
printf("difference of the elements stored in an array :%d",diff);
}
}
output :
enter the number of elements : 2
enter the elements :
20
10
difference of the elements stored in an array :10
#include<stdio.h>
#include<conio.h>
void main()
{
int a[i],diff=0,n;
printf("enter the number of elements :");
scanf("%d",&n);
printf("enter the elements:");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<=n;i++)
{
diff=a[i]-diff;
printf("difference of the elements stored in an array :%d",diff);
}
}
output :
enter the number of elements : 2
enter the elements :
20
10
difference of the elements stored in an array :10
#include<stdio.h>
#include<conio.h>
void main()
{
int a[i],diff=0,n;
printf("enter the number of elements :");
scanf("%d",&n);
printf("enter the elements:");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<=n;i++)
{
diff=a[i]-diff;
printf("difference of the elements stored in an array :%d",diff);
}
getch();
}
output :
enter the number of elements : 2
enter the elements :
20
10
difference of the elements stored in an array :10
Login to add comment