Question
Question 1
Question 1B
Assume that you were given the term grades for the CIS* 1500 class in winter 2013. The first line of the input data is a single integer specifying the number of students N in the class. The second line contains what each item (there are 7 of them) is out of, and the final N lines are the raw integer scores for each student as follows: assl_mark ass2_mark ass3_mark ass4_mark ass5_mark midterm final If each assignment is out of 90, the midterm is out of 50, and the final is out of 100, the term grades for a 3 students may look like: 3 90 90 90 90 90 50 100 81 80 70 75 77 44 77 50 40 60 44 55 33 22 90 88 70 90 44 50 11 You will need to create a random data for a 20 students, and you will need to write a C program to calculate the class average for each assignment, midterm and final in terms of a percent (i.e., 77%) rounded to the nearest percentage point. Your output should look like this: There are 3 students in this class. The average for assignment #1 is 82% The average for assignment #2 is 77% The average for assignment #3 is 74% The average for assignment #4 is 77% The average for assignment #5 is 65% The average for the midterm is 85% The average for the final is 37% Write a C program that looks for the ideal-number in the range between 0 and 20, 000. Here is the definition for the ideal-number: rightarrow It is any number whose factors, including 1 sum to the number. For example, 28 is an ideal-number because 28 = 1+ 2 + 4 + 7 +14. Your job is to write a function called ideal-number that helps the program user to know if any number in the provided range is an ideal-number. Use this function in a program that determines and prints all the ideal-number between 20 and 20, 000. To make sure that your program is working fine, you will need to print the factors of each ideal-number you will find matching the criteria of the ideal-number in the provided range.
Explanation / Answer
#include<stdlib.h>
#include<io.h>
#include<stdio.h>
#include<time.h>
#include<math.h>
int idealnumber(int n)
{
int sum=0;
for (int i = 1; i <= n/2; i++)
{
if(n%i==0)sum+=i;
}
if(sum==n)return 1;
else return 0;
}
int main()
{
for (int i = 0; i <= 20000; i++)
{
if(idealnumber(i))
printf("%d is an ideal number ",i);
}
return 0;
}
//this is second part