

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This programming assignment is for Introduction to Programming course. It was assigned by Prof. Abhimoda Arora at Alagappa University. It includes: Program, Calculate, Mathematical, Constant, Pi, Circle, Quadrants, Radius, Area, Random, Number
Typology: Exercises
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Qno1 Write a C++ program to calculate the mathematical constant of PI: (a) Imagine a circle, whose area is given by: Area=PIR^ (b) Now imagine that you divide the circle exactly into 4 quadrants. (c) The area of one quadrant is hence: Area=0.25PIR^ (d) Now let us set the radius to be R=1; (e) The equation hence becomes: Area=0.25PI (f) So we can simply say: PI = Area* Now the big question is how do you calculate the area of the gray shaded quadrant of the circle above? Use a random number generator and guess effectively the correct answer. (Hint: use rand() from
Q no 2 Write a program which will print all the pairs of prime numbers whose sum equals the number entered by the user. Store these prime numbers and randomly select any prime number from that array Q no 3 An integer number is said to be perfect number if its factors including 1 (but not the number itself) sum to the number. For example, 6 is a perfect number because 1+2+3=6. Write a function perfect that determines if parameter number is a perfect number, and returns a boolean value true if number is perfect other wise returns false. Use this function in a program that prints perfect numbers between 1 and 1000. Store these perfect numbers in an array