0% found this document useful (0 votes)
2 views

ASM1

The document contains four programming questions that require writing code to perform specific tasks based on given inputs. Each question specifies the input format, expected output, and constraints on modifying existing code. The tasks include calculating the area of a triangle using Heron's formula, evaluating a mathematical expression, counting occurrences of a number in an array, and converting lowercase 'a' to uppercase in a string.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

ASM1

The document contains four programming questions that require writing code to perform specific tasks based on given inputs. Each question specifies the input format, expected output, and constraints on modifying existing code. The tasks include calculating the area of a triangle using Heron's formula, evaluating a mathematical expression, counting occurrences of a number in an array, and converting lowercase 'a' to uppercase in a string.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Question 1 (2 marks)

The given file Q1.c already contains statements to input data for 3 sides of a triangle. You should write
statements so that print out the area of that triangle.
Notes:
Heron's formula for three side lengths a, b, c:

- Do not edit given statements in the main function.


- You can create new function(s) if you see it is necessary.
- The output result is formatted in two decimal places
Sample input and output:
Input: Side1 = 3, Side2 = 3, Side3 = 4
After processing: result = 4.47
Output for marking:
OUTPUT:
4.47

Question 2:

(3 marks)
The given file Q2.c already contains statements to input the integer variable named n. You should write
statements to calculate expression value:
1 1 1 1
S=1+ + 2 + 3 + …+ n
3 3 3 3
Notes:
- You can create new function(s) if you see it is necessary.
- Do not edit given statements in the main function.

Sample input and output:


Input: n =3
After processing: result = 1.481
Output for marking:
OUTPUT:
1.481
Question 3:

(2 marks)
The given file Q3.c already contains statements to input data for the integer 1-D array and the integer
variable named 'x'. You should write statements to print out the count of how many times 'x' appears in
the array.
Notes:
- You can create new function(s) if you see it is necessary.
- Do not edit given statements in the main function.

Sample input and output:


Input: n = 5
Array: 1 8 8 4 8
x=8
After processing: 3
Output for marking:
OUTPUT:
3

Question 4:
(3 marks)

The given file Q4.c already contains statements to input a string s. You should write statements to
convert the character 'a' in string s to uppercase.
Notes:
- You can create new function(s) if you see it is necessary.
- Do not edit given statements in the main function.

Sample input and output:


Input: hahaha
Output:
hAhAhA

You might also like