Sie sind auf Seite 1von 2

Class : XI    

Subject : Computer Science 
Topic:  Loops 
Worksheet 4 
 
 
Name……………………………………… Sec……….   Date……………….. 
 
 
Q1)  WAP to print all the special numbers from 1 till 100. A special number is defined as any two 
numbers whose sum of digits and the product of digits when added give the original number. 
 

Q2)  WAP to find GCD or HCF and LCM of two numbers. 

Greatest Common Divisor (GCD) or Highest Common Factor (HCF) of two positive integers is the 
largest positive integer that divides both numbers without remainder. It is useful for reducing 
fractions to be in its lowest terms. See below on methods to find GCD. 
Lowest Common Multiple (LCM) of two integers is the smallest integer that is a multiple of both 
numbers 

 
 Q3)  WAP to find the sum of all the even and odd numbers within the given range. For example 
if the range is 10 and 20 
Sum of even numbers= 10+12+14+16+18+20 
Sum of odd numbers= 11+13+15+17+19 
 
 
Q4) WAP to find the sum of squares upto the given number(n). For ex: 
N=4 
Sum of squares= 1+4+9+16 
 
 
Q5) WAP to print the following pattern: 
     For n=4: 
 
      1234321 
      123  321 
      12      21 
      1          1 

Q6)  WAP to find the sum of the following series: 

a) S= 7+ 77 + 777+.........n terms 
b) S= 1 + x2 + x3 + x4 +............+ xn 

Q7)  WAP to find whether a number is pal prime or not. 

c)  A pal prime is a prime number that is also a palindrome number. The first few 
decimal palindrome primes are: 

1 The Shri Ram School


d) 2, 3, 5, 7, 11, 101, 131, 151, 181, 191, 313, 353, 373, 383, 727, 757, 787, 797, 919, 
929, … 
Q8)  WAP to print the following patterns: 

a) For n=4: 
 
abcdcba 
abc  cba 
ab      ba 
a          a 
ab      ba 
abc   cba 
  abcdcba 

b) For n=3: 
 
                       1 
                   1  2 
1 2  3 

 
Q9. Write the corresponding statement in JAVA for the following expressions using math 
function: 
 

a)  

b)  

c)  
 
Q10)  A private company has its employees divided into three grades as per their basic pays as 
follows: 
 
Grade I: Basic >= 10000 
DA = 40 % of Basic 
HRA= 30 % of Basic 
Grade II: Basic > 5000 but < 10000 
DA = 40 % of Basic 
HRA = 30 % Basic 
 
Grade III: Basic < 5000 
DA = 20 % of Basic 
HRA = 10 % of Basic 
Total Salary = Basic + DA+ HRA 
 
Write program to input Basic and Grade and print total salary as per above rules.  

2 The Shri Ram School

Das könnte Ihnen auch gefallen