1.write a program in C# to find a given point which is
inside in a circle. Given circle's radius and its center
point?
2.Write a program in C# to generated 20 prime numbers
greater than a given number? (It should be more efficient
for large numbers also)
3. Write a Code to check whether a given point is inside a
circle or not? given Circle's raduis and its center point.
4. using oops concept, design an elevator do not forget
buttons on each floor..

Answers were Sorted based on User's Feedback



1.write a program in C# to find a given point which is inside in a circle. Given circle's rad..

Answer / chandra kiran

answer for 3rd question
static void Main(string[] args)
{
Console.Write("Please Enter the radius of the circle : ");
int r = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Please Enter the center of the circle ");
Console.Write("Please Enter x coordinate of the centre : ");
int x1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Please Enter y coordinate of the centre : ");
int y1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Please Enter the Point ");
Console.Write("Please Enter x coordinate of the point : ");
int x2 = Convert.ToInt32(Console.ReadLine());
Console.Write("Please Enter y coordinate of the point : ");
int y2 = Convert.ToInt32(Console.ReadLine());
int check =Convert.ToInt32(Math.Sqrt(Math.Pow(x2-x1,2)+Math.Pow(y2-y1,2)));
if (check < r)
Console.WriteLine("Inside the Circle");
else if (check == r)
Console.WriteLine("On the Circle");
else
Console.WriteLine("Outside the Circle");
}
//don't enter centre of the circle and point (1,2) ,(5,6) like this enter each coordinate individually

Is This Answer Correct ?    8 Yes 2 No

1.write a program in C# to find a given point which is inside in a circle. Given circle's rad..

Answer / ganesh

take 4 textboxes , cx=centre x, cy=centre y, r=radius,
x=x co-oridnate, y=y co-ordinate.
double d;

calculate the distnace between centre and point taken
if distance less than radius(inside) else outside

simple


d = Math.Sqrt(Math.Pow((int.Parse(cx.Text) - int.Parse(x.Text)), 2) + Math.Pow((int.Parse(cy.Text) - int.Parse(y.Text)), 2));


if (d <Double.Parse( r.Text))
Label1.Text = "inside";
else
Label1.Text = "outside";

Is This Answer Correct ?    5 Yes 1 No

Post New Answer

More C Sharp Interview Questions

Can we have static indexer in c#?

0 Answers  


Explain different properties of object oriented systems.

0 Answers  


What is toint32 c#?

0 Answers  


Contrast DTDs versus XSDs. What are their similarities and differences? Which is preferred and why ?

1 Answers  


Hi to all..I have to create an intranet application on C#.NET windows Application so please please let can you people help me as iam new in .NET and if u have any samples or website address from where i can get sample please let know.

0 Answers   ABB, TCS,






what is IFormatable

0 Answers   Wipro,


What is or operator in c#?

0 Answers  


Can an Assembly have multiple versions

13 Answers   TCS,


Explain manifest & metadata.

2 Answers   Wipro,


What is wpf c#?

0 Answers  


Use of Checked and UnChecked operators?

2 Answers   TCS,


Is post back in c#?

0 Answers  


Categories