Some Logical Questions for BASIC & C++

1.  Accept the value of A, B & C then calculate result of formula.

            R = 6.5 (A + B)2 - 7.3((B + C)).5

                         (A + C)

2.  Write a program to accept ages (in year) of 100 peoples. Then count & display the number of people lies between each age categories. The output is look like this,

            INDIAN AGE SURVEY

            Children (1-9)        :

            Toddlers (10-17)      :

            Adults (18-25)        :

            Married (26-60)       :

            Retired (61-80)       :

            Elder (81-99)         :

            Centurion (above 100) :

3.  Write a program to accept any 10 numbers. Then count how many numbers are odd, even or zero among them.

4.  Write a program to accept any 10 numbers. Then count how many numbers are positive, negative or zero among them.

5.  Write a program to display the factorial of first ten natural numbers.

6.  Write a program to accept any number between 1 to 10, and then display the number in word.

    (Hints: If the input number is 3 the program should print three words on screen)

7.  Write a program to accept three numbers and find which one is greater.

8.  Writes a program to accept a number, check whether the numbers is prime number or not. If number is prime, then display “PRIME NUMBER” or display “NOT PRIME NUMBER”.

9.  Write a program to display all prime numbers between 100 to 200.

10. Write a program to display the factorial of a given number.

11. Write a program to accept 10 numbers. Display the highest number and lowest number. Also calculate the sum and average of numbers.

12. Write a program to accept 10 numbers. Display the highest and second highest number among them.

13. Write a program to accept 10 numbers. Display the second highest number among them.

14. Accept 10 numbers and count how many numbers are divisible by 2 & 3 among them.

15. Accept a numbers and find out the given number is divisible by 5 or not, if not then print the nearest number from the given number which is divisible by 5.

16. Write a program to accept a number then print the number in reverse order and also display the number of digits present in it. (E.g. If the input number is 225, the sum of digits is 9 and number of digits is 3).

17. A number is called as Armstrong number if the sum of qube of each digit of the number is equal to that number. Write a program to accept a number then check whether the given number is Armstrong number or not. (E.g. 153 is a Armstrong number because 153= 13 + 53 +33).

18. Write a program to check whether the numbers 207, 531, 964, 153, 100 is an Armstrong number or not.

19. Write a program to display all three digit Armstrong number.

20. Write a program to check whether the given number and the reverse of the number is same or not.

21. Write a program to check whether all the digits of the given number are same type or not (i.e. all are odd numbers or all are even numbers).

22. Write a program to accept a number and then add all digits until you found a single digit number. If that single digit number is 1, then that number is called magic number. (for example if number is 2345 then sum of its digits becomes 14, further sum of this digits is 5)

23. Write a program to accept a number then check whether the number is perfect number or not. A number is called perfect number, if the sum of all factors of the number is equal to that number. (For e.g. 6 is a perfect number. factor of 6 is 1, 2 & 3 and the sum of the number 1+2+3=6.


Some General Type Questions for BASIC & C++

1.  Print total number of resident in PARK ROAD out of handbook, which has five pages and each page, has four entries. Design a program in BASIC to output the total number of entries at the end of the page.

2.  Prepare an interactive program in BASIC to input the basic salary of 15 persons. Each of them gets 15% of the basic as HRA, 15% of the basic as Conveyance allowance and 10% of the basic as Entertainment allowance. The total salary is calculated by adding Basic + HRA + Conveyance + Entertainment Allowance. Calculate how many out of 15 got salary above 3000 and also print the total salary of each person.

3.  A library charge a fine for books returned late. Following are the fines: first five days 40 paisa per day, Six to ten days 65 paisa per day, above 10 days 80 paisa per day. Design a program in BASIC to calculate the fine assuming that a book is returned N days late.

4.  The sum of the cubes of the first natural numbers is given by the following formula:  13+23+33+43+...+N3 = [N (N + 1) 2]/2

    It is intended to write a program to compute the value of S where S = 32 + 42 + 52 + 62 + ... + N2

5.  The present population of a country is PO and it increases by 5% every year. The population (P) after n years is given by the formula: P = PO (1.05)n. Write a program in BASIC to find the population every year for the next ten days.

6.  The telephone department wishes to compute monthly telephone bills for its customers using the following rules. Minimum Rs. 250 for first 80 message units, plus 60 paisa per unit for next 60 units, plus 50 paisa per unit for next 60 units, plus 40 paisa per unit for any units above 200. Write a program in BASIC that calculates the monthly bill, with input MESSAGE (the number of message units) and CUSTNO (the registration number of a customer). Display the bill under the heading.

CUSTOMER NO      UNITS            AMOUNT(Rs)

7.  Write a program in BASIC to read in all the given numbers below and then print them out with all the 0’s to the extreme left. The sequence of the number should not be disturbed.

    Data: 1, 0, 2, 45, 3, 0, 46, 8, 0 and 5

    Output: 0, 0, 0, 1, 2, 45, 3, 46, 8 and 5

8.  Write a program in BASIC to enter the three sides of a triangle. Decide whether it is a scalene, isosceles or equilateral triangle.

9.  Developed a BASIC program to prepare and print a frequency distribution table of the following data: 35, 21, 11, 0, 5, 17, 12, 38, 47, 36, 9, 23, 4, 12, 8, 29, 32, 39, 4, 44.

    In to categories: 0-9   10-19   20-29   30-39   40-49

    The output should state categories and the corresponding frequencies in two columns.

10. Write a program and draw a flowchart to compute BI-monthly telephone charges for 800 subscribers. Use the following information:

    Fixed BI-monthly rent: Rs.380

    Free calls during two months: 120

    Charge per call beyond free limits up to 100 calls: Rs. 1.00

    Charge per call in excess of 100 calls: Rs. 1.25

11. Draw a flowchart to make a telephone call to a person, assuming that the following procedural steps are to be performed in the given order:

    i)   To begin, lift the receiver.

    ii)  Dial the number.

    iii) If the line is engaged, the receiver is to be put down, wait for some time and dial again.

    iv)  Otherwise call for the person.

    v)   If person is attending, talk to him or her.

    vi)  Otherwise, leave a message.

    vii) Replace the receiver to end.

12. A number of answer scripts with scores 0 to 99 awarded after marking are to be searched for finding:

    (i)   Number of answer script marked

    (ii)  Percentage of candidates getting 85 and above

    (iii) Percentage of candidate below 40

    Write programs in BASIC to take the score as input and then output the three quantities required.

13. Write a program in BASIC with supporting documentation to enter any five real numbers and calculate x where:

    X = Product of integer portion

           Sum of decimal portion 

14. A security man paid at the hourly rate (R) for the first 40 hours of work in a week. Thereafter, he is paid at 1.25 times of the hourly rate (R) for the next 16 hours and at 1.5 times of the hourly rate (R) for the further hours of work in the week. Taking the numbers of hours (H) and the rate per hour (R) as input, the weekly wages (W) is to be calculated.

15. The acceleration due to gravity as a function of altitude is given by:

        g = 32.17(4390/4390+h)2            if h>0

        g = 32.17(1+h/4390)2               if h£0

    Where, ‘h’ is height above the sea level in statute miles and ‘g’ is the acceleration due to gravity in it per sec2. Write a program in BASIC to printout the value of g with every corresponding value of h from -4 to 10 in step of 1.

16. A computer salesman gets commission on the following basis:

                Sales Amount            Commission Rate

                Rs. 0 - 20,000            3%

                Rs. 20,000 - 50,000       12%

                Rs. 50,001 and more       31%

    Given the sales as input, write a program in BASIC that will calculate his commission and printout sales, rate of commission and earning.

17. Present value of an annuity is given by the formula

    T=(1-1/(1+i) n)/i          P=AT

    Where A is the amount deposited, I is the rate of interest and n is the number of years of investment. Write a program in BASIC to calculate the present value for 80 depositors for different periods of time at 12% rate of interest.

18. Write a program to input the code of a particular item, quantity purchased and rate. Then ask if any more item to be purchased. If not then calculate the total purchased price and print it along with gift to be presented. The gifts to the customers are given in the following manner:

        Amount of Purchase (Rs.)        Gift

        Between 100 to 500             A key ring

        Between 500 to 1000            A leather purse

        Above 1000                     A pocket calculator

    Before ending the program a “Thank You” message should be printed to all the customers.

19. In an election out of 1249 voters in a booth, only 861 voters use their franchise correctly. If five candidates are contesting, write a program to find the number of invalid and valid voters. And the percentage of valid voters received by each candidate.

20. A list contains both positive and negative integers. The length of the list is unknown. But from their origin it was known none of the numbers is as big as 1000. This number has thus been added at the end of the list where it serves as a flag. Write a program in BASIC to summing and counting the positive and negative numbers separately. Assume that none of the numbers is zero.

21. A teacher takes a roll call every day. Rather then ticking off the names of those present, she prefers to marks those present with 1 and those absent with 0. There are 15 boys in a class and the register on Monday morning look like this: 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1 and 0. Write a BASIC program that the teacher can use and get an output, which will tell the teacher how many boys are present and how many are absent.

22. The production (P) of crude oil of a country in millions of barrel may be estimated by the following set of equations, where t represent the times in years. P=5+3t, for 0£t£3 and P=14+(T-5/2) 2, for t>3, Write a program in BASIC to print the quantity of production for every year from t=1 to 10.

23. A computerised ticket counter of an underground metro rail station charges the each ride at the following rate:

        AGE                       AMOUNT/HEAD

        18 or above                    Rs. 5

        5 or above but below 18        Rs. 3

        Accompanying kids below 5      NIL  

    Write a program in BASIC, which takes as input the number of people of various age groups, and print a ticket. At the end of the journey, the program states the number of passengers of different age group who traveled and the total amount received as collection of fares.

24. Write a basic program to read any 15 numbers. Print the following:

        Numbers   Squares      Integer Part     Decimal Part

25. Write a program with supporting documentation to calculate the value of S where S = 1x2 + 2x3 + 3x4 + 4x5 + ... + 19x20