Initial Basics – Algebra – Problem #19
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
Write C code which reads a floating point number x and an integer n ( 0 to 10 both inclusive ) from keyboard and computes the following. (a) SUM = x + (x+1) + (x+2) + (x+3) + …….. + (x+n) (b) PRODUCT = x * (x+1) * (x+2) * (x+3) * …….. * (x+n) (c) Take as input another positive floating point number y. (d) Now, enter an operator from the keyboard and perform the operation. The operator can be any of the following + (addition) - (subtraction) * (multiplication) / (division) and % (remainder) Calculate x <operator> y. (e) Print x, the sum, the product and the floating point number you obtain from the calculator.