Professional Documents
Culture Documents
CSC2203 Jan 2015
CSC2203 Jan 2015
This paper consists of SIX (6) questions. Answer any FOUR (4) questions in the
answer booklet provided. All questions carry equal marks.
Question 1
ii.
int main(int argc, char **argv)
{
char acString[]=”Assignment”;
printf(“%d %d”,strlen(acString),sizeof(acString));
return 0;
}
(c) Write a C program that request for an integer number and determine whether it
is prime or not a prime number.
(10 marks)
Question 2
(a) Write a program that accepts two numbers from a terminal and call a function
named min_max in main to determine the minimum and the maximum number.
By using the pointers, the value of minimum and maximum are send back to
main() and to be printed out.
(12 marks)
(b) Write a C program that reads in ten integer numbers and store them in an array
called Numbers[]. The program should display the total number of odd number
and total number of even number in the array and display the content
accordingly.
(13 marks)
Question 3
(a) Write a C program using nested for loop and produce the output shown below:
(8 marks)
CSC2203 (F) / Page 3 of 5
#include <stdio.h>
main()
{
int i = 10;
do{
printf("Hello %d\n", i );
i = i -1;
if( i == 6 )
{
break;
}
}while ( i > 0 );
}
(5 marks)
(c) Write a C program that will request for a radius value. Pass the argument to a
function called fnArea() to calculate the area of the circle.
(12 marks)
Question 4
(a) Write a program that stores the following test marks in the array called Marks.
The program reads the contents of the test marks and display the scores and the
grade on the screen based on the following marks ranges.
(b) You can calculate your Body Mass Index (BMI) by using the following
formula:
BMI = Weight (kg)
Height (m) x Height (m)
Write a program that will calculate the BMI and display the following message
according to the BMI result calculated.
CSC2203 (F) / Page 4 of 5
(10 marks)
(c) What is the difference between scanf() and gets()?
(3 marks)
Question 5
(a) Write a code segment using a sentinel-loop structure to ensure marks entered by
the user is between 0 and 100. Display appropriate error message if an invalid
mark is entered.
(5 marks)
(c) Write a function square() that will take an integer and return its square. Write
another function cube() that will take an integer and return its cube. Implement
the two functions, in a program to produce a neatly printed table containing a
list of integers, their square and their cubes as shown below. The integer should
run from 1 to 10.
Sample output:
Question 6
Name : Amit
Address :
City : Seremban
Postcode: 70300
Age : 20
Salary : $4,000
(5 marks)
(b) Write a C program that prompt for the number of names to be entered. Store the
name in an array called Names[]. Using bubble sort technique, sort the names
in ascending order. Display the number of passes done and the sorted list
(15 marks)
--THE END –
CSC2203(F)/JAN15/ JEYARANI/030315