Page 182 - CA_Blue( J )_Class10
P. 182

t = n * n;
                            while(t>0)
                            {
                                r=t%10;
                                s=s+r;
                                t=t/10;
                            }
                            if(s==n)
                                System.out.println(n+ " Neon Number");
                            else
                                System.out.println(n+ " Not Neon Number");
                        }
                    }
                 31.  Write a program to input two numbers and print the Greatest Common Divisor (GCD) of them.
                Ans. import java.util.*;
                    class gcd
                    {
                        public static void main () {
                             Scanner sc = new Scanner (System.in);
                             int i, s = 0, a, b, g;
                             System.out.println("Enter two numbers:");
                            a=sc.nextInt();
                            b=sc.nextInt();
                            if(a>b)
                               g = a;
                            else
                               g = b;
                            i=g;
                            while(i>=1)
                            {
                               if(a%i==0 && b%i==0)
                               {     break;
                               }
                               i--;
                            }
                             System.out.println("GCD of " + a + " and " + b + " is " + i);
                        }
                    }
                 32.  Write a program to input the Computer Applications marks of 10 students and print the grades each student got according to
                    the following criteria.
                     Marks                 Grade
                     Above 90              A
                     70 to 89              B
                     50 to 69              C
                     <50                   D
                Ans. import java.util.*;
                    class marks_grade
                    {
                        public static void main () {
                             Scanner sc = new Scanner (System.in);
                             int i, m;
                             for (i=1; i<=10; i++)
                             {
                                System.out.println("Enter marks of student : " + i);
                    m=sc.nextInt();
                     if(m>90)


                180180  Touchpad Computer Applications-X
   177   178   179   180   181   182   183   184   185   186   187