Arrays question and answers in C#.net and we are solving critical programs using arrays it can be used to store multiple values at a time.
Arrays Questions and Answers
class A
{
static void main(0
{
int sum=0;
int[] Ar=new int[6];
for(int i=0;i<=5;i++)
{
Console.WriteLine("enter a number");
Ar[i]=int.parse(Console.ReadLine());
sum=sum+Ar[i];
}
Console.ReadLine("The sum is"+sum);
}
Q)Write a program to accept 7 numbers from console and find the sum of even and sum of odd use arrays?
class A
{
static void main()
{
int esum=0,osum=0;
int[] Ar=new int[7];
for(int i=0;i<=6;i++)
{
Console.WriteLine("enter a number");
Ar[i]=int.parse(Console.ReadLine()0;
if(Ar[i]/2==0)
esum=esum+Ar[i];
else
osum=osum=Ar[i];
}
Console.WriteLine("the even sum is'+esum);
Console.WriteLine("the odd sum is"+osum);
}
}
Q)Write a program to reverse a string?
class A
{
static void main()
{
String s="satyam";
char[] ch=s.ToCharArray[];
for(int i=5;i>=0;i--)
{
Console.WriteLine(ch[i]);
Console.WriteLine();
}
}
Q)Write a program to check the given string is polindrome or not?
class A
{
static void main()
{
String s=console.readline();
char[] ch=s.ToCharArray();
int length=ch.length;
while(length-1>=0)
{
revs=revs+ch[length-1];
}
if(s==revs)
{
Console.WriteLine("polindrome");
}
else
Console.WriteLine("not polindrome");
}
}
Q)Write a program to reverse the words?
class A
{
static void main()
{
String S="Ram,is,good,boy";
String[] s1=s.split();
for(int i=s1.length-1;i>=0;i--)
{
Console.WriteLine(s1[i]+"");
}
Console.WriteLine();
}
Friends you like my programming please share to your friends and you want more programs please comment on my post.
0 comments:
Post a Comment