Array c programming absolute value?
I have to write a code for a program that takes an array with n elements
and then checks if there are two consecutive values of the array with
equal absolute values.The results must be displayed as following:
|v[i]|=|v[i+1]|
|v[j]|=|v[j+1]|
So
#include <stdio.h>
int i,j,n;
{
int v[100];
printf ("Please write n:");
scanf("%d",&n);
for (i=0;i<n,i++)
printf( "Write the element %d",i);
scanf("%d", &v[i]);
}
for (i=0;i<n;i++)
abs(v[i])=abs(V[i+1]);
printf("Elements are %d',v[i]");
for (j=0;j<n;j++)
abs(v[j])=abs(v[j+1]);
printf("Elements are %d',v[j]");
When I run this,it shows like a thousand errors, but I think that the
mistakes are logical. Can you tell me where am I wrong?
No comments:
Post a Comment