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 |
A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream
what is the format specifier for printing a pointer value?
Define macros.
write a program to interchange the value between two variable without using loop
What is define c?
how many header file is in C language ?
44 Answers College School Exams Tests, CTS, IBM, IMS, Infosys, ME, Sign Solutions, Wipro, XVT,
write a function for strtok()??
Can you explain the four storage classes in C?
What is sorting in c plus plus?
the constant value in the case label is followed by a a) semicolon b) colon c) braces d) none of the above
#include<stdio.h> int f(int,int); int main() { printf("%d",f(20,1)); return 0; } int f(int n,int k) { if(n==0) return 0; else if(n%2)return f(n/2,2*k)+k; else return f(n/2,2*k)-k; } how this program is working and generating output as 9....?
‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.