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.



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

Answer / 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

More C Interview Questions

Stimulate calculators to perform addition,subtraction,multiplication and division on two numbers using if/else statement?

1 Answers   IBM,


What is int main () in c?

0 Answers  


how will you write a program on linked lists using JAVA programming???????????

1 Answers   Keane India Ltd,


how does the C compiler interpret the following two statements p=p+x; q=q+y; a.p=p+x; q=q+y b.p=p+xq=q+y c.p=p+xq; q=q+y d.p=p+x/q=q+y

4 Answers   TCS,


Program to find the absolute value of given integer using Conditional Operators

6 Answers   N Tech,


write a program to interchange the value between two variable without using loop

1 Answers  


write a program to concatenation the string using switch case?

0 Answers  


why array index always starts from zero??

4 Answers   TCS,


In c language can we compile a program without main() function?

0 Answers  


How does the assert() function work?

2 Answers  


What is a structure in c language. how to initialise a structure in c?

0 Answers  


what is the difference between postfix and prefix unary increment operators?

3 Answers  


Categories