Become Our Fan on Social Sites!

Facebook Twitter

Google+ RSS YouTube

Thursday 3 October 2013

C program for to remove extra spaces between words

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