Reference no: EM132629834
HEETCM102A Introduction to Digital Electronics and Programming Fundamentals
Assessment : C Programming
Part A:
Write a program to select your question from the Part B.
Program must tell the user (you) to enter the student ID no (student ID has 9 digits. eg: 202012345). Then the program must add up all the digits and find the sum of the digits. Then program must divide that number by 5 and find the remainder. Based on the remainder value,display a message advising the student their relevant question from Part
B. Questions are assigned as below:
• If remainder = 0; Select Question 1.
• If remainder = 1; Select Question 2.
• If remainder = 2; Select Question 3.
• If remainder = 3; Select Question 4.
• If remainder = 4; Select Question 5.
Ex:
If your student ID is 202012345, the sum of all the digits is: 2+0+2+0+1+2+3+4+5 = 19. When 19 is divided by 5, the remainder is 4. So this student must select Question 4 from part B and answer that only.
Part B : Only select the question relevant to you and answer that ques- tion.
Question 1 Problem on converting decimal numbers to octal values.
Tell the user to enter a number greater than 50. Then check whether the user entered number is greater than 50 or not. If the number is not greater than 50, display the message "Please enter a number greater than 50!".
If the user has entered a number greater than 50, your program must calculate the OCTAL representation of that number using a function, and finally display the correct OCTAL number.
Question 2 Problem on area and perimeter of triangles.
Tell the user to enter the lengths of the sides of a triangle (a,b and c). Use a function to check whether the triangle is right-angled or not ( you can use Pythagoras' theorem for this).
If the triangle is right-angled, then you must find the find the area of the triangle and print it out. If the triangle is NOT right-angled, then you must find the perimeter of the triangle and print that out.
Note: If you want to use the sqrt() to find the square root, please type the following two lines, at the start of the program.
include<stdio.h> include<math.h>
Question 3 Problem on Body Mass Index.
Tell the user to enter his/her height (in m) and weight (in kg). Then calculate the user's Body Mass Index (BMI) using the following formula.
BMI = weight in kg/(height in m)2
After BMI is calculated, according to the following list, a message should be displayed
according to the calculated BMI value.
• If BMI value is less than 18.5 - Underweight
• If BMI value is between 18.5 and 24.9 - Healthy weight range
• If BMI value is between 25 and 29.9 - Overweight
• If BMI value is 30 or over - Obese
Question 4 Problem on finding the factorial of a number.
Tell the user to enter a positive number. Then check whether the user entered number is positive or not. If the number entered is not positive, display the message "Please enter a positive number!".
If the user has entered a positive number, you must write a program to calculate the
factorial of that number and display the value.
Note: If user entered 5, then the factorial of 5 is calculated as 5*4*3*2*1 = 120. So the program must display a message saying "The factorial of 5 = 120"
Question 5 Problem on a 5 digit number.
Tell the user to enter a 5 digit number. Then check whether the user entered number has 5 digit number or not. If the number entered does not have 5 digits, display the message "Please enter a 5 digit number!".
If the user entered a 5 digit number, use a function to calculate the square of each digit and add them together and display the answer.
12 + 22 + 32 + 42 + 52 = 55. So the program must display a message saying: Note: If user entered 12345, then the sum of squared digits will be calculated as: "The sum of squared digits of 12345 = 55