if you do not create a new object, it will take only 2 names in input, i.e. 1st i/p banana and second i/p grapes can be entered but can't enter 3rd i/p apple
If I give apple a as small and Banana B as capital and Grapes G as capital means the out put will be Banana Grapes apple Even if we gave the input in capital also it should come in alphabetical order so pls write a program for that
@@sharonsam5687 hi. This is normal sorting program. If gave names ( Bala ,anbu,Ram ) like this also I want in alphabetically but Its not coming it's coming Bala,Ram,anbu.
source code:
String name[]={"BANANA","APPLE","PINEAPPLE","MANGO","KIWI"};
int n = name.length; //array length=5
String tmp;
for(int i=0; i
Why do you creat 2 objects of Scanner can't we just use 1 ?
Ur teaching awsome.Subscribed to ur channel bro.
public class Program
{
static void Main(string[] args)
{
string[] str = {"Banana,Grapes,Apple" };
var splitstring = str.Select(x=> x.Split(",")).ToArray();
string[] result = splitstring[0].ToArray();
string temp = string.Empty;
for(int i =0;i< result.Length; i++)
{
for(int j =i +1;j< result.Length; j++)
{
if (result[i].CompareTo(result[j]) > 0)
{
temp = result[j];
result[j] = result[i];
result[i] = temp;
}
}
}
foreach(var x in result)
{
Console.WriteLine(x);
}
}
}
Explanation superb...
amazing explanation sir
Why do you create two objects of scanner?
Same question
if you do not create a new object, it will take only 2 names in input, i.e. 1st i/p banana and second i/p grapes can be entered but can't enter 3rd i/p apple
If I give apple a as small and Banana B as capital and Grapes G as capital means the out put will be
Banana Grapes apple
Even if we gave the input in capital also it should come in alphabetical order so pls write a program for that
for(int i=0;i
@@sharonsam5687 hi. This is normal sorting program. If gave names ( Bala ,anbu,Ram ) like this also I want in alphabetically but Its not coming it's coming Bala,Ram,anbu.
Just do one thing. While sending the name to comapareTo method use toUpperCase() or toLowerCase() methods.
Nyc explanation ❤
Thanks 🙂
Why do you creat 2 objects of Scanner can't we just use 1 ?
Why do you creat 2 objects of Scanner can't we just use 1 ?