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

Programing I Sample

The document contains two programming exercises. The first asks to write programs to calculate a sum formula and solve an equation. The second asks to write a program to manage student marks data from a file, including options to insert, read, display, rank by average, and calculate average for a class.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Programing I Sample

The document contains two programming exercises. The first asks to write programs to calculate a sum formula and solve an equation. The second asks to write a program to manage student marks data from a file, including options to insert, read, display, rank by average, and calculate average for a class.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

SAMPLE EXERCISES PROGRAMMING I

Exercise 1: (5 points)
1. Write a program to calculate the sum as the expression with the given value n: (2 points)
𝑛"1
1
𝑆𝑢𝑚 = %
𝑛
1
2. Write a program to solve equation as follows: (3 points)
𝑎𝑥1 − 𝑏𝑥$ = 1
(𝑎𝑥1 + 𝑏𝑥$ = 0
Given values of a and b from input, find x1 and x2

Exercise 2: (5 points)
Suppose you are developing a program to manage students’ marks of 4 subjects.
The information of a students is described as follows:
struct students{
char name[30];
char[10] class;
float average;
};

The records of the students list are stored in a file named “students.dat”.
Write the program that has the interface as follows:
Please choose:
1. Insert students records to the database.
2. Read all students information from database
3. Print/show information of all students
4. Ranking of students based on the average.
5. Calculate the Average mark of all students of a given class name.
0. Exit
When the user chooses:
0. The program will exit. (0.5 point)
1. The program will require the user to prompt information of student such as: name, class and
mark average. Then, all of the information will be stored to the database file name: students.dat.
(1.5 point)
2. The program will read all the file named “student.dat” and store in an array. (1 point)
3. The program will display all student information (each student information will be display on
a line) from the array. (0.5 point)
4. The array will be sorted descending and display to the output (1 point)
5. The program will require the user to enter a class name, then it will take the average mark of
all students in that class and print it out. (1.5 point)

You might also like