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

  • 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...
  • How do I increase organic traffic within One Month
    There’s plenty you can do boost organic site traffic at no cost except your time: Optimize for your personas, not search engines.  ...
  • Top Most Differences between windows,web and console applications
    You want to get clarity on any topic the differences very helpful at that time and in these we are having top 5 differences between conso...
  • 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 ...
  • How to Remove Audio From Any Video Using VLC Media Player?
    Step by Step Procedure for  Remove(Mute) Audio in a Video Using VLC  Player A picture is worth a thousand words and a video is worth a t...
  • Best Methods To Get A Cheap Home Insurance Deal!
    Cheap Home Insurance Home Insurance is seen as a luxury but in all honesty it is a necessity especially in the case of natural disast...
  • Connected and Disconnected Data Access Architecture
    The Ado.Net Frame Work Supports Two Models of Data Access Architectures one is Connected Oriented architecture and second One is Disconnec...
  • Best Good Afternoon wishes greetings and quotes
    Top Most Good Afternoon Wishes Good Afternoon wishes are gives a relaxation in afternoon time.This wishing can be done between 12 to 3 p...
  • 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...
  • INTERESTING PSYCHOLOGICAL FACTS ABOUT GIRLS Love In Valentines Day
    Girls Love And Caring Love feelings are very interesting to every one and moreover girls feelings are very interesting and amazing a...

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•