P. 1
C-loops and control statement-7

# C-loops and control statement-7

4.0

|Views: 496|Likes:

See more
See less

05/09/2014

pdf

text

original

# LOOPs and Basic control statements

1 Calculate n! (i.e. n factorial) where a. if n>0 then n! = 1*2*3*4*5…*n b. n=0 then n!=1 c. n<0 then n! is not defined 2. Check whether given number is Armstrong or not? [Armstrong number means sum of cube of digits is equivalent to number itself. E.g. 153 is an Armstrong number.] 3. Print Fibonacci series: - 1,1,2,3,5,8,13… (Hint: After the first two numbers in the series, each number is the sum of the two preceding numbers.) 4. .Wap To read integers (until user enters 0 to stop); find sum, average, max and min of these integers added by user. 5. Determine and print the sum of the following harmonic series for a given value of n: a. 1 + ½ + 1/3 + ¼ +. …+ 1/n b. Given that PI = 4(1-1/3+1/5+1/9+1/14+…) Write a program to evaluate the value of PI as the sum of 10 terms or 20 terms ,… or 100-terms and print as per the following format c. No. of Terms | Value of PI d. -------------------------------------e. <<your ans>> f. <<your ans>> g. . . h. . . i. . . j. <<your ans>> k. * 6. Witnesses at the scene of a crime gave descriptions about two suspects who were in hurry. The first suspect was described as being short and heavy (height <165 cm and weight >90 kg) and the second suspect was described as being tall and thin (height >190 cm and weight <60 kg). Write a c-program to input height and weight of known criminal-pairs in the area and to printout it is suspect or not. a)Read above problem. Now read a no. N from user. Then read heights and widths of N criminal-pairs and print whether they are criminals or not. 7. The cost of operating an electrical device is determined by the formula –