Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

1. Write a program to reverse every second word in a
given sentence.

Answer Posted / lalit

#include <stdio.h>
#include <string.h>

void main()
{
int i, j = 0, k = 0, x, len;
char str[100], str1[10][20], temp;

printf("enter the string :");
scanf("%[^
]s", str);

/* reads into 2d character array */
for (i = 0;str[i] != ''; i++)
{
if (str[i] == ' ')
{
str1[k][j]='';
k++;
j=0;
}
else
{
str1[k][j]=str[i];
j++;
}
}
str1[k][j] = '';

/* reverses each word of a given string */
for (i = 0;i <= k;i++)
{
len = strlen(str1[i]);
for (j = 0, x = len - 1;j < x;j++,x--)
{
temp = str1[i][j];
str1[i][j] = str1[i][x];
str1[i][x] = temp;
}
}
for (i = 0;i <= k;i++)
{
printf("%s ", str1[i]);
}
}

Is This Answer Correct ?    0 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the use of fflush() function?

1090


how we can make 3d venturing graphics on outer interface

4840


Disadvantages of C language.

1113


What is meant by recursion?

1059


How do you define a function?

1035


What is c value paradox explain?

1105


What are the different types of linkage exist in c?

1035


How to write c functions that modify head pointer of a linked list?

994


What does int main () mean?

1038


Can math operations be performed on a void pointer?

1058


the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters

2302


simple program of graphics and their output display

2007


What is the purpose of void in c?

1071


Where static variables are stored in memory in c?

1009


how to construct a simulator keeping the logical boolean gates in c

2264