Given two strings like x=?hello? and y=?open?, remove any
character from string x which is also used in string y,
thus making the result x=?hll?.
Answer Posted / preeti
Lttle correction in above answer.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string str = "mohim";
string str1 = "mo";
remove(str, str1);
}
private static void remove(string str,string str1)
{
char[] abc;
abc = str.ToCharArray();
char[] bcd;
string str4 = "";
bcd = str1.ToCharArray();
for (int i = 0; i < bcd.Length; i++)
{
for (int j = 0; j < abc.Length; j++)
{
if (abc[j] != bcd[i])
{
str4 = str4 + abc[j];
}
}
abc = str4.ToCharArray();
str4 = "";
}
str = "";
for (int j = 0; j < abc.Length; j++)
{
str = str + abc[j];
}
Console.Write("str : ");
Console.Write(str)
}
}
}
output will be
------------------------
str : hi
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Why is oop useful?
Templates mean
write a program to enter a string like"sunil is a good boy and seeking for a job" not more than 10 characters including space in one line,rest characters should b in other line.if the next line starts from in between the previous word,then print whole word to next line.
What is overriding in oops?
Write a program to sort the number with different sorts in one program ??
What is overriding in oop?
What are the benefits of polymorphism?
Why do pointers exist?
if i have same function with same number of argument but defined in different files. Now i am adding these two files in a third file and calling this function . which will get called and wht decide the precedence?
Why is abstraction used?
What is interface? When and where is it used?
Why do we use oops?
There are two base class B1,B2 and there is one class D which is derived from both classes, Explain the flow of calling constructors and destructors when an object of derived class is instantiated.
How to hide the base class functionality in Inheritance?
What is variable example?