Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. sample code

sample code

Scheduled Pinned Locked Moved C#
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Trustapple
    wrote on last edited by
    #1

    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

    S 1 Reply Last reply
    0
    • T Trustapple

      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

      S Offline
      S Offline
      Sandeep Kumar
      wrote on last edited by
      #2

      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

      T 1 Reply Last reply
      0
      • S Sandeep Kumar

        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

        T Offline
        T Offline
        Trustapple
        wrote on last edited by
        #3

        ThankYou Sandeep ....i am a beginner hence the confusion :)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups