Read full document

Program in C

By | Feb. 2011
Page 1 of 2
//1.Write a program in C# using command line arguments to display a welcome message. The message has to be supplied as input in the command line using System; class prac1 { public static void Main(string[] args) { foreach(string k in args) { Console.Write(k+" "); } Console.ReadLine(); } } //2.Write a program in C# to find the area of a circle, given its radius. using System; class prac2 { public static void Main() { float radius=8.9f; float pi=3.14f; float area; area=pi*radius*radius; Console.WriteLine("The Area Of Circle whose Radius is {0} :- {1}",radius,area); Console.ReadLine(); } } //3.Write a program in C# to find the area of polygon – triangle and rectangle by using multiple constructors using System; class prac3 { prac3(double half,double length,double height) { double areaoftriangle=half*length*height; Console.WriteLine("The Area of Triangle of length {0} and height {1} is: {2}",length,height,areaoftriangle); Console.ReadLine(); } prac3(double len,double breadth) { double areaofrectangle=len*breadth; Console.WriteLine("The Area of Rectangle of length {0} and height {1} is: {2}",len,breadth,areaofrectangle); Console.ReadLine(); } public static void Main() { prac3 obj1=new prac3(0.5,4.2,3.8); prac3 obj2=new prac3(5.2,2.6); Console.ReadLine(); } } //4.Write a program in C# to add and multiply two numbers and display the results. Demonstrate the use of ref and out parameters in this program. using System;

class prac4 { public static void add(ref int num1,ref int num2) { int res_add=num1+num2; Console.WriteLine("The Addition Of {0} and {1} using is : {2} ",num1,num2,res_add); Console.ReadLine(); } public static void product(out int number1,out int number2) { number1=10; number2=10; int res_product=number1*number2; Console.WriteLine ("The Product Of {0} and {1} using is : {2}",number1,number2,res_product); Console.ReadLine(); } public static void Main(string[] args) { int num1; int num2; num1=10; num2=10; add(ref num1,ref num2); int number1; int number2;...
Hide

Rate this document

What do you think about the quality of this document?

Share this document

Let your classmates know about this document and more at Studymode.com