sample code
-
hi, in this simple code my program is not going into "area = r * r * 3.14;" the output i am getting is 0000 { class ReturnTest { static int r; static double area; static double CalculateArea() { Console.WriteLine("the value of r is ", r); Int32.Parse(Console.ReadLine()); area = r * r * 3.14; return area; } static void display() { Console.WriteLine("The area is {0:0.00}", area); Console.ReadLine(); } public static void Main() { ReturnTest.CalculateArea(); ReturnTest.display(); } } } can you tell me why??? thanks for the help j
-
hi, in this simple code my program is not going into "area = r * r * 3.14;" the output i am getting is 0000 { class ReturnTest { static int r; static double area; static double CalculateArea() { Console.WriteLine("the value of r is ", r); Int32.Parse(Console.ReadLine()); area = r * r * 3.14; return area; } static void display() { Console.WriteLine("The area is {0:0.00}", area); Console.ReadLine(); } public static void Main() { ReturnTest.CalculateArea(); ReturnTest.display(); } } } can you tell me why??? thanks for the help j
Trustapple wrote:
Int32.Parse(Console.ReadLine());
you are converting the string value into int but you are not assigning to any variable for that reason you are getting value as 0 as r value is 0 i think your statement should be like......
r = Int32.Parse(Console.ReadLine());
Regards, Sandeep Kumar.V
-
Trustapple wrote:
Int32.Parse(Console.ReadLine());
you are converting the string value into int but you are not assigning to any variable for that reason you are getting value as 0 as r value is 0 i think your statement should be like......
r = Int32.Parse(Console.ReadLine());
Regards, Sandeep Kumar.V
ThankYou Sandeep ....i am a beginner hence the confusion :)