Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q2. Write a pseudo-code or C++ code that takes as an input two numbers that defines the start and end of a range. It then
Q2. Write a pseudo-code or C++ code that takes as an input two numbers that defines the start and end of a range. It then prints all the integers in this range whose square also falls in the same range. (10 marks) Sample example: Input: 2 and 12 Output: 23 Explanation: since 2*2= 4 and 3*3=9 falls within the range 2-12. Input: 10 and 150 Output: 10 11 12 Q3: A number N is abundant if the sum of all its positive divisors except itself is more than N. (10 marks) Examples: N = 10, positive divisors of 10 are 1, 2 and 5. Their sum is 1+2+5 i.e. 8 which is less than 10. So, N (i.e. 10) is not an abundant number N = 12, positive divisors of 12 are 1, 2, 3, 4, and 6 . Their sum is 1+2+3+4+6 i.e. 16 which is not less than 12. So, N (i.e. 12) is an abundant number Your task is to write a pseudo code which asks user to enter a number N and displays if the number is abundant or not. Note: Your output should be either "This number is Abundant" or "This number is NOT abundant". You may the use the following if-structure, that checks if a number i is a divisor of N. if (N mod i is 0) "This means that i is a divisor of N" Q2. Dry run the following pseudo code and write the output corresponding to different inputs in the box provided. Mod is the modulas operator, and it calculates the remainder of an integer division. For example 11 mod 4 is 3. (8 marks) START roll_no = last 4 digits of your roll number n = (2* roll_no + 12)/2 - roll_no i=1 while ( i less than or equal to n) print "1/", i if (i%2 is 1) print"+" else print ".- i =i+1 print roll_no Output: the output corresponding to different inputs in the box provided. Mod is the modulas operator. (12 marks) START input a number from user and store in variable userInput; counter=1 result=0 if (userInput mod 3 is O AND counter is 1) result=result+10; counter = counter + 5; else if (counter>1) { result = result+100; output/print "counter = " counter, " result = ", result if (userInput mod 5 is 0) { result=result + userinput; counter=counter+1; output/print "counter = " counter, "result = ", result
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started