Write a program to accept two strings of Odd lengths. Then
take all odd characters from one string and even characters
from the other and concatenate and produce a string.



Write a program to accept two strings of Odd lengths. Then take all odd characters from one string..

Answer / mani

#include<stdio.h>
void main()
{
char *str1[10],*str2[10],str3[10],str[4];
boolean check1,check2;
int i=0,j=1;
do
printf("enter the first string of odd length");
scanf("%s",str1);
printf("enter the second string of odd length");
scanf("%s",str2);
check1=testlen(&str1);
check2=testlen(&str2);
}
while(check1!=true && check2!=true);

while( *str1!='/o' || *str2!='/o')
{
if(str1[i]!='/o)
str3[i]=str1[i];

if(str2[i]!='/o)
str3[i+1]=str2[i];

i+=2;
}

while( *str1!='/o' || *str2!='/o')
{
if(str1[j]!='/o)
str4[j]=str1[j];

if(str2[j]!='/o)
str4[j+1]=str2[j];

i+=2;
}
printf("The value of string1 is %s",str1);
printf("The value of string1 is %s",str2);
printf("The value of string1 is %s",str3);
printf("The value of string1 is %s",str4);

}

boolean testlen(char *c) //function
{
int count;
while(*c++!='/o')
count++;
if(count%2!=0)
return true;
else
return false;
}

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More C C++ Errors Interview Questions

I'm having trouble with coming up with the correct code. Do I need to put a loop? Please let me know if I'm on the right track and what areas I need to correct. I still don't have a good grasp on this programming stuff. Thanks =) The assignment was to write a program using string functions that accepts a coded value of an item and displays its equivalent tag price. The base of the keys: 0 1 2 3 4 5 6 7 8 9 X C O M P U T E R S Sample I/O Dialogue: Enter coded value: TR.XX Tag Price : 68.00

3 Answers   UCB,


How to upgrade LOOP environment, I just mean, how can i make loop statement editable ? I just try some program using loop statement and checking it in multiple compilers. Every compiler showing different output, what's the wrong ? is it a compiler based problem, or loop based problem, tell me why ? and what will be the debugging process, for this kind of problem ?

1 Answers  


How to create a program that lists countries capitals when country is entered? (Terribly sorry, I'm a complete novist to coding with C, am looking for inspiration and general tips on how to code and create this program.)

0 Answers  


UINT i,j; i = j = 0; i = ( i++ > ++j ) ? i++ : i--; explain pls....

5 Answers  


write the value of x and y after execution of the statements: int x=19,y; y=x++ + ++x; x++; y++;

0 Answers  






Find the error (2.5*2=5) (a) X=y=z=0.5,2.0-5.75 (b) s=15;

3 Answers  


class test { int a; public: test(int b):a(b){} void show(){ cout<<a; } }; void main() { test t1; test t2(5); t1.show(); t2.show(); } }

1 Answers  


printy(a=3,a=2)

3 Answers  


Assume that the int variables i and j have been declared, and that n has been declared and initialized. Write code that causes a "triangle" of asterisks of size n to be output to the screen. Specifically, n lines should be printed out, the first consisting of a single asterisk, the second consisting of two asterisks, the third consistings of three, etc. The last line should consist of n asterisks. Thus, for example, if n has value 3, the output of your code should be * ** *** You should not output any space characters. Hint: Use a for loop nested inside another for loop.

2 Answers   HCL,


void main() { int i=5,y=3,z=2,ans; clrscr(); printf("%d",++i + --z + i++ + --i * ++y); i=5,y=3,z=2; ans=++i + --z + i++ + --i * ++y; printf("\n%d",ans); getch(); } Its output is 37 and 31.... Please explain me why its different How it works.....

2 Answers  


what is meant for variable not found?

3 Answers  


Write a C program to enter 10 integer numbers through one variable and count how many of them are even using while loop ?

2 Answers  


Categories