Technology Guruu

  • Home
  • Site Info
    • About Us
    • Disclaimer
    • Privacy Polacy
  • Home
  • Digital Marketing
    • SEO
    • SMM
    • SEM
  • Quotes
  • Technical
  • Java
  • .Net
    • C#.Net
    • ASP.Net
  • Keychains

Saturday, 2 April 2016

C#.Net Logical Questions And Answers

 Akansha     18:00:00     TechnicalQuestions     No comments   

Logical C#.Net Questions 

logicalquestions
logical questions

1.Write a console program to print the following pattern?

1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication21
{
class Program
{
static void Main(string[] args)
{
int i, j;
for (i = 1; i <= 5; i++)
{
for (j = 5; j > i; j--)
{
Console.Write(" ");
}
for (j = 1; j <= i; j++)
{
Console.Write(" "+j);
}
for (j = j - 2; j >= 1; j--)
{
Console.Write(" "+j);
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}

2.Write a console program to print the following pattern?

*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*
namespace triangle
{
class Program
{
static void Main(string[] args)
{
int i, j, k, n = 6, l = 3;
for (i = 1; i <= 5; i++)
{
for (k = n; k >= 1; k--)
{
Console.Write(" ");
}
n--;
for (j = 1; j <= i; j++)
{
Console.Write(" " + "*");//i
}
Console.WriteLine("");
}
for (i = 4; i >= 1; i--)
{
for (k = l; k >= 1; k--)
{
Console.Write(" ");
}
l++;
for (j = 1; j <= i; j++)
{
Console.Write(" " + "*");//i
}
Console.WriteLine("");
}
Console.ReadLine();
}
}
}

3.Write a console program to print the following pattern?

*
* *
* * *
* * * *
* * * * *
namespace triangle
{
class Program
{
static void Main(string[] args)
{
int i, j, k, n = 6, l = 3;
for (i = 1; i <= 5; i++)
{
for (k = n; k >= 1; k--)
{
Console.Write(" ");
}
n--;
for (j = 1; j <= i; j++)
{
Console.Write(" " + "*");//i
}
Console.WriteLine("");
}
Console.ReadLine();
}
}
}

4.Write a console program to print the following pattern?

* * * * *
* * * *
* * *
* *
*
namespace triangle
{
class Program
{
static void Main(string[] args)
{
int i, j, k,l = 4;
for (i = 1; i <= 5; i++)
{
for (k = l; k >= 1; k--)
{
Console.Write(" ");
}
l++;
for (j = 1; j <= i; j++)
{
Console.Write(" " + "*");//i
}
Console.WriteLine("");
}
Console.ReadLine();
}
}
}

5.Write a console program to print the following pattern?

1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
namespace triangle
{
class Program
{
static void Main(string[] args)
{
int i, j, k, n = 6, l = 3;
for (i = 1; i <= 5; i++)
{
for (k = n; k >= 1; k--)
{
Console.Write(" ");
}
n--;
for (j = 1; j <= i; j++)
{
Console.Write(" " + i);//*
}
Console.WriteLine("");
}
for (i = 4; i >= 1; i--)
{
for (k = l; k >= 1; k--)
{
Console.Write(" ");
}
l++;
for (j = 1; j <= i; j++)
{
Console.Write(" " + i);//*
}
Console.WriteLine("");
}
Console.ReadLine();
}
}
}

6.Write a console program to print the following pattern?

c
c o
c o m
c o m p
c o m p u
c o m p u t
c o m p u t e
c o m p u t e r
static void Main(string[] args)
{
Console.WriteLine("enter u r string");
string a=Console.ReadLine();
string b = null;
int i,j;
for(i=0;i<8;i++)
{
for(j=0;j<i+1;j++)
{
b = b + a[i];
Console.Write(a[j]);
}
Console.WriteLine("\n");
}
Console.ReadLine();
}

7.Write a console program to print the following pattern?

1 2 3 4 5
6
7
8
9
10 11 12 13 14 15
static void Main(string[] args)
{
int i;
for(i=1;i<=15;i++)
{
if(i<5)
{
Console.Write(i+" ");
}
else if (i <10)
{
Console.WriteLine(i + " ");
}
else
{
Console.Write(i + " ");
}
}
Console.ReadLine();
}

8.Check whether given letter is vowel or not?

static void Main(string[] args)
{
Console.WriteLine("enter a letter");
char ch = char.Parse(Console.ReadLine());
switch(ch)
{
case 'a':Console.WriteLine("it is a vowel");
break;
case 'e':Console.WriteLine("it is a vowel");
break;
case 'i':Console.WriteLine("it is a vowel");
break;
case 'o':Console.WriteLine("it is a vowel");
break;
case 'u':Console.WriteLine("it is a vowel");
break;
default:Console.WriteLine("invalid character");
break;
}
Console.ReadLine();
}

9.Check the given string is polindrome or not?

static void Main(string[] args)
{
Console.WriteLine("enter u r name");
string a =Console.ReadLine();
string b=null;
for(int
i=a.Length-1;i>=0;i--)
{
b=b+a[i];
}
if(a==b)
{
Console.WriteLine("string is polindrome");
}
else{
Console.WriteLine("string is not a polindrome");
}
Console.ReadLine();
}
}

10.reverse a given number?

static void Main(string[] args)
{
int n = 1234, m = n,sum=0;
while (n >= 1)
{
int r = n % 10;
Console.Write(r);
n = n / 10;
}
Console.ReadLine();
}

11.Write a program for sum of & count of even numbers?

static void Main(string[] args)
{
Console.WriteLine("enter u r range");
int n = int.Parse(Console.ReadLine());
Console.WriteLine("list of even no's are:");
int sum = 0, cnt = 0;
for (int i = 2; i <= n; i = i + 2)
{
Console.WriteLine(i);
sum = sum + i;
cnt++;
}
Console.WriteLine("sum of even numbers are:" + sum);
Console.WriteLine("number of even no's are:" + cnt);
Console.ReadLine();
}

12.Write a console program to print the following pattern?

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
static void Main(string[] args)
{
int i=1, j=1;
while(i<=5)
{
for (j = 1; j <= i; j++)
{
Console.Write(j);
}
i++;
Console.WriteLine("");
}
Console.ReadLine();
}
Dear friends you also try your own programs and post to www.goodfriends5.com and i do any mistakes please comment on my post and also share your friends through Facebook,twitter,Google+..
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Older Post Home

0 comments:

Post a Comment

Popular Posts

  • Missing My Friend Quotes : Friendship Day Quotes 2017
    Friends today my article about missing friends and moments with them. Here you are seen the best friendship quotes and some  feelings when...
  • Love Failure Quotes and Sad valentines day Quotes
    We Love Someone is a easy process sometime takes long time to love someone love others within short period but anyway always love dependin...
  • Brief description about Delegates
    Introduction about delegates and why delegates are came the main purpose of delegates how to useful and what are the advantages and disadv...
  • Na Tanu Samjhawan Ki Song lyrics
    Na Tanu Samjhawan Ki Song Lyrics With English Translation Movie : Humpty Sharma ki Dulhaniya Song : Samjhawan Song Singer : Arijit ...
  • Detail Introduction about C#.Net
    Brief Introduction about C#.Net  Introduction C#.Net is the one of the Programming Language the .Net Framework also contains ano...
  • Wonderful sayings about Life.
    I Believe Follow  Things(Life Quotes) I Believe I believe: ********** Believe in Life ********** That we don't have to chan...
  • Brief Description about Multicast Delegate
    Multicast delegate is an extension of normal delegate. It helps you to point more than one method at a single moment of time. Multicast ...
  • Brief description about properties
    Properties in C#.Net Properties Property is a member of a class which we will use to assign the value to a variable as well as whi...
  • Top 10 valentine's day Quotes and Greetings wishes
    All Lovers have Anxiety in Valentines day because it is a festival to all lovers in these they enjoy a lot and celebrate the Valentine...
  • Valentines day poems and wishes or Quotes
    A friendship that like love is warm; A love like friendship, steady.we are having the most difference between love and Friendship you mus...

Categories

  • Entertainment (67)
  • TechnicalQuestions (58)
  • Quotes (11)
  • C#.Net (8)
  • Java (8)
  • ValentinesDay (4)
  • SEO (3)
  • Home
  • About Us
  • Disclaimer
  • Privacy Policy
  • Sitemap

Copyright © 2015-2017 Good Friends 5.All Rights Reserved• And Our Sitemap • All Logos and Trademark Belongs To Their Respective Owners•