Program:
#include<stdio.h>int main()
{
int n;
int i, j;
printf("n: ");
scanf("%d",&n);
int a[n];
printf("enter elements\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n-1;i++)
{
printf("( ");
if(a[i+1]>a[i])
{
for(j=a[i];j<=a[i+1];j++)
printf("%d ",j);
}
else if(a[i+1]<a[i])
{
for(j=a[i+1];j<=a[i];j++)
printf("%d ",j);
}
else printf("%d %d ",a[i],a[i]);
printf(") ");
}
return 0;
}
No comments:
Post a Comment