ASSIGNMENT(CHAPTER 5)

ASSIGNMENT 4

                           (CONTROL STATEMENT-DECISION +LOOPING)

DRAW ALGORITHM AND FLOWCHART 

 

  1. WAP to read a number from the user and test whether the number is negative. [ Show message “ THE NUMBER IS NEGATIVE” if it is a negative number , otherwise show nothing. [if-statement]
  2. WAP to read the percentage of marks obtained by a student in SLC and +2 level. Display message “CONGRATULATIONS!!! You have first division in both SLC and +2” if both levels have percentage greater than or equal to 60.[nested if]
  3. WAP to read a number from user and determine whether the number is even or odd.[if-else]
  4. WAP to read three numbers from user and determine the largest among them.[using conditional operator]
  5. WAP that reads total marks of a student in seven subjects. Then calculate the percentage and determine the division. Use following condition:[if-else if]

i)Percentage greater than or equal to 80 = distinction

ii)Percentage between 60-79 = first division

ii)Percentage between 45-59 = second  division

ii)Percentage between 32-44 = third  division

ii)Percentage less than or equal to 31 = fail

  1. WAP to find the second largest (or middle number ) among three numbers.
  2. WAP that asks an arithmetic operator and two operands and performs the corresponding operation on the operands using the SWITCH statement.
  3. WAP that to determine all roots(real and imaginary) of a quadratic equation by using both [switch and if else] statement 
  4. The monthly electricity bills to be computed as follows: 

i)Minimum Rs 80/- for up to 20 units

ii)Rs 7.30 per unit for next 100 units

iii)Rs 9.00 per unit for any units beyond 120 units

WAP to compute monthly bills for a given number of units consumed by a customer.

  1. A bank has introduced an incentive policy. A bonus of 2% of the balance is given to everyone, irrespective of their balances and 5% is given to female account holder if their balance is more than Rs 5000/-. WAP to represent this policy and calculate balance after bonus.
  2. WAP that finds the value of y based on the value of x in the following function. y={2x+300 for x<50, 200 for x=50 and 50x-100 for x>50}
  3. WAP to calculate the factorial of a number [while  loop]
  4. WAP that ask an integer number n and calculate sum of all natural numbers from 1 to n[for loop]
  5.  WAP to read a number from the keyboard until a zero or a negative number is keyed in . Finally calculate sum and average of entered numbers.
  6. WAP to display a multiplication table of 5-10.
  7.  WAP to determine whether a number is prime or not.[use break statement]
  8. WAP that asks for a number n from  user and then display  only even numbers from 2 to n[continue statement]
  9. WAP to ask two numbers . Display message” EITHER NUMBER IS NEGATIVE” if either number is negative ; otherwise display message” BOTH NUMBER ARE POSITIVE”.[goto statement]
  10.  WAP that asks for a number n from user and then display only even number from 2 to n [use continue statement]
  11. WAP to ask two numbers. Display message” EITHER NUMBER IS NEGATIVE” if either number is negative ; otherwise display message “BOTH ARE POSITIVE”.
  12. WAP to find HCF and LCM of two numbers.
  13. WAP to generate Fibonacci series of n terms entered by the user using iteration.
  14. WAP to count the number of digits in a number.
  15. WAP to compute the sum of digits of a given integer number.
  16. WAP to reverse the digits of a number (if a number is 12345, the reversed number is 54321)
  17. WAP  to check whether the entered number is perfect or not.
  18. WAP to find the number of and sum of all integers greater than n1 and less than n2 and divisible by  7, where n1<n2 and n1 & n2 are read from the keyboard.
  19. WAP to display all Armstrong numbers in a certain range [from n1 to n2] given by user.
  20. Program to compute cosine series 

 cos(x) = 1-x^2/2!+x^4/4!+x^6/6!+...+x^n/n!

  1. Program to compute cosine series 

Sin x = x - x^3/3! + x^5/5! -x^7/7! +...

  1.  WAP to convert decimal numbers to binary.
  2. WAP to convert binary to decimal numbers.
  3. WAP to read a number, find its reverse and check whether it is PALINDROME or not.
  4. WAP to display  all prime numbers between n1 and n2 where n1<n2 and n1 &n2 are read from the keyboard.
  5. WAP to check if the entered number is STRONG or not.
  6. WAP to read a number and find its PRIME FACTOR. 
  7. WAP to input decimal numbers and display its digits in words with reverse order.
  8. WAP to input a 5-digit number and display its digits in words.
  9. WAP that reads a character and performs following operations according to the choice inputted by the user.
  1. Display “ IT IS VOWEL” if the entered character is a vowel otherwise “ IT IS CONSONANT”.
  2. Display “ IT IS DIGIT” if the entered character is a member of digit , otherwise display the ASCII value of entered character

 

  1. WAP TO CHECK WHETHER A NUMBER IS ARMSTRONG OR NOT.