If string contains more than one spaces then following C program removes extra spaces between words.
#include<stdio.h>
void main()
{
int no, i, j, arr[100], temp[100];
printf("Enter Total No. of Elements : ");
scanf("%d", &no);
printf("Enter Elements : ");
for (i = 0; i < no ; i++)
scanf("%d", &arr[i]);
for (i = no - 1, j = 0; i >= 0; i--, j++)
temp[j] = arr[i];
for (i = 0; i < no; i++)
arr[i] = temp[i];
printf("\nReverse Array : ");
for (i = 0; i < no; i++)
printf("%d ", arr[i]);
}
0 comments :
Post a Comment