Initial Basics – Algebra – Problem #19

IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive

Difficulty: Medium

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.

Back to Lab Problems
Initial Basics/Algebra/Problem #19

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #19

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.