Page 352 - CA_Blue( J )_Class10
P. 352

13      {
                14         while(n>0)

                15         {
                16            s=s+(n%10);
                17            n=n/10;

                18         }
                19         System.out.println("Sum of the digits of "+t+" is :"+s);

                20      }
                21      public static void main()
                22      {

                23         instance_variable ob = new instance_variable();
                24         ob.input();

                25         ob.display();
                26      }
                27  }

              You will get the following output:
              Enter a number : 1203
              Sum of the digits of 1203 is: 6

              14.3.4 Argument Variables
              An argument is a value that is passed to a method when it is called. It is also called actual parameter. When variables
              are declared in method prototype to receive values are called formal parameters. Internally, the values of the actual
              parameters are copied to the formal parameter when the method is invoked.

                Program 7    To find the area of a circle.


                 1  import java.util.*;
                 2      class argument_variable
                 3      {

                 4         void area (double radius)
                 5                {

                 6            System.out.println("Area of a circle : "+ 3.142 * radius *
                                      radius);
                 7         }
                 8         public static void main()
                 9         {
                10            double r=4.5;

                11            area(r);
                12                }
                13      }



                350350  Touchpad Computer Applications-X
   347   348   349   350   351   352   353   354   355   356   357