The Loop Control Structure | Let us C solution with details description and tutorials | yashwant kanetkar

The Loop Control Structure | Let us C solution with details description and tutorials |  yashwant kanetkar


S.NChapterS.NChapter
1Decision Control Structure5Arrays
2The Loop Control Structure6Puppetting On Strings 
3The Case Control Structure7Structures
4Function and Pointer8Input/Output in C


[B] Attempt the following:

(a)Write a program to calculate overtime pay of 10 employees. Overtime is paid at the rate of Rs. 12.00 per hour for every hour worked above 40 hours. Assume that employees do not work for fractional part of an hour.

Show Solutions     Hide Solutions

(b)Write a program to find the factorial value of any number entered through the keyboard. 

Show Solutions     Hide Solutions

(c)Two numbers are entered through the keyboard. Write a program to find the value of one number raised to the power of another. 

Show Solutions     Hide Solutions

(d)Write a program to print all the ASCII values and their equivalent characters using a while loop. The ASCII values vary from 0 to 255. 

Show Solutions     Hide Solutions

(e)Write a program to print out all Armstrong numbers between 1 and 500. If sum of cubes of each digit of the number is equal to the number itself, then the number is called an Armstrong number. For example, 153 = ( 1 * 1 * 1 ) + ( 5 * 5 * 5 ) + ( 3 * 3 * 3 )

Show Solutions     Hide Solutions

(f)Write a program for a matchstick game being played between the computer and a user. Your program should ensure that the computer always wins. Rules for the game are as follows: ? There are 21 matchsticks. ? The computer asks the player to pick 1, 2, 3, or 4 matchsticks. ? After the person picks, the computer does its picking. ? Whoever is forced to pick up the last matchstick loses the game. 

Show Solutions     Hide Solutions

(g)Write a program to enter the numbers till the user wants and at the end it should display the count of positive, negative and zeros entered. 

Show Solutions     Hide Solutions

(h)Write a program to find the octal equivalent of the entered number. 

Show Solutions     Hide Solutions

(i)Write a program to find the range of a set of numbers. Range is the difference between the smallest and biggest number in the list. 

Show Solutions     Hide Solutions

------------------------------------------------
for, break, continue, do-while
[E] Attempt the following:

(a)Write a program to print all prime numbers from 1 to 300. (Hint: Use nested loops, break and continue) 

Show Solutions     Hide Solutions

(b)Write a program to fill the entire screen with a smiling face. The smiling face has an ASCII value 1. 

Show Solutions     Hide Solutions


(c)Write a program to add first seven terms of the following series using a for loop: 1/1! + 2/2! + 3/3! + ......... 

Show Solutions     Hide Solutions

(d)Write a program to generate all combinations of 1, 2 and 3 using for loop. 

Show Solutions     Hide Solutions

(e) According to a study, the approximate level of intelligence of a person can be calculated using the following formula: i = 2 + ( y + 0.5 x ) Write a program, which will produce a table of values of i, y and x, where y varies from 1 to 6, and, for each value of y, x varies from 5.5 to 12.5 in steps of 0.5.

Show Solutions     Hide Solutions

(f)Write a program to produce the following output:
       A B C D E F G F E D C B A
       A B C D E F     F E D C B A
       A B C D E            E D C B A
       A B C D                   D C B A
       A B C                           C B A
       A B                                  B A
       A                                        A 

Show Solutions     Hide Solutions

(g)Write a program to fill the entire screen with diamond and heart alternatively. The ASCII value for heart is 3 and that of diamond is 4. 

Show Solutions     Hide Solutions

(h)Write a program to print the multiplication table of the number entered by the user. The table should get displayed in the following form. 29 * 1 = 29 29 * 2 =58 .... 

Show Solutions     Hide Solutions

 (i) Write a program to produce the following output:
                1
               2 3
              4 5 6
             7 8 9 10

Show Solutions     Hide Solutions

(j)Write a program to produce the following output:
                1
               1 1
              1 2 1
             1 3 3 1
            1 4 6 4 1

Show Solutions     Hide Solutions

(k) A machine is purchased which will produce earning of Rs. 1000 per year while it lasts. The machine costs Rs. 6000 and will have a salvage of Rs. 2000 when it is condemned. If 12 percent per annum can be earned on alternate investments what would be the minimum life of the machine to make it a more attractive investment compared to alternative investment?

Show Solutions     Hide Solutions

 (l)  When interest compounds q times per year at an annual rate of r % for n years, the principle p compounds to an amount a as per the following formula
a = p ( 1 + r / q ) ^ nq
Write a program to read 10 sets of p, r, n & q and calculate the corresponding as.

Show Solutions     Hide Solutions

(m)The natural logarithm can be approximated by the following series.
(x-1)/x + 1/2((x-1)/2)^2 + 1/2((x-1)/2)^3 + ...
If x is input through the keyboard, write a program to calculate the sum of first seven terms of this series. 

Show Solutions     Hide Solutions

Comments

Popular posts from this blog

Puppetting on string | Let us C solution with details description and tutorials | yashwant kanetkar

If cost price and selling price of an item is input through the keyboard, write a program to determine whether the seller has made profit or incurred loss. Also determine how much profit he made or loss he incurred