
latihan untuk setw dan setprecision
Bentuk soalan : Show output of the program above.
Lecturer : MOHD NAZRI BIN IBRAHIM
Subject : BCT1113 COMPUTER PROGRAMMING
CLASS : 1 BMET
*keputusan di bawah adalah tertakluk kepada keputusan mesyuarat senat TATiUC.
No. | Matric No. | GRED |
1 | 10B02044 | B |
2 | 10B02101 | B |
3 | 10B02102 | C |
4 | 10B02103 | B- |
5 | 10B02105 | B- |
6 | 10B02106 | B- |
7 | 10B02107 | A- |
8 | 10B02108 | B+ |
9 | 10B02109 | B+ |
10 | 10B02110 | B- |
11 | 10B02111 | B |
12 | 10B02112 | B+ |
13 | 10B02113 | A- |
14 | 10B02114 | B |
15 | 10B02116 | B |
16 | 10B02117 | B |
17 | 10B02118 | B |
18 | 10B02119 | B |
19 | 10B02121 | A |
20 | 10B06013 | B+ |
21 | 10B12031 | B- |
22 | 10C12016 | B |
QUIZ 2#2 - FUNCTION
Write a prototype for the following functions:
Example : Computing an average of three integers.
double Tambah (int, int, int)
1. Computing an average of two integers. double average (int ,int );
2. Computing a sales commission, given the sales amount and the commission rate. double comm (double , double)
3. Computing a revised salary, given the current salary and percentage of increment. double gajibaru (double, double);
4.Printing the calendar for a month, given the month and year. void cetakbulan(int, int);
5.Computing a square root. double sqrt(double)
6.Testing whether a number is even, and returning true if it is. bool ujiNoGenap (int);
7.Testing whether a score is passed and returning trure if it is. bool ujimarkah (double);
8. Printing a message a specified number of times. void cetakmsg(string,int);
9. Computing the monthly payment, given the loan amount, number of years, and annual interest rate. double bayaran(double, int, double);
10.Finding the corresponding uppercase letter, given a lowercase letter. char hurufbesar(char);
Write a program that asks the user to type 10 integers and writes the sum of these integers. Use either while or do-while or for loop. Start with a pseudocode and flowchart.
Flowchart
C++ Program
#include<iostream.h>
int main(void)
{
int n;
int sum =0;
int counter = 1;
while(counter <=10)
{
cout<<"sila masukkan no ";
cin>>n;
sum = sum +n;
counter = counter +1;
}
cout<<"Hasil tambah 10 nombor ialah : "<<sum;
return 0;
}
1. Respond with the correct answer by marking either True "T" or False "F" for each question.
a) High-level languages include Basic, FORTRAN, COBOL, Pascal, C, C++, C#, and Java
b) Compiler: translates a program written in a high-level language machine language
c) Preprocessor directives begin with # and are processed by a the preprocessor
d) Use the compiler to: Check that the program obeys the rules
e) Linker: Combines object program with other programs provided by the SDK to create executable code
f) Programming is a process of problem solving
g) Algorithm: Step-by-step problem-solving process
h) Two popular approaches to programming design: - 1) Structured 2) Object-oriented
i) The structured design approach is also called Modular Design
2. Print the output of the following C++ statement. If nothing prints, then answer "nothing". Assume x=3 and y=2.
Example) cout<<x; 2
a) cout<<y;
b) / * cout<<y; */
c) // cout<<x+y;
d) cout<<x<<y;
e) cout<<x<<endl<<y;
f) cout<<x+y;
g) cout<<"x+y="<<x+y;
h) cin>>x%y;
i) cout<<++x;
j) cout<<y++;
3. Print the output of the following C++ statement. If nothing prints, then answer "nothing".
a) if(1<3)
cout<<"Yes";
else
cout<<"No";
b) char race='M';
if ((race=='m') ||( race =='M')) then
cout<<"Malay";
else
cout<<"Others";
c) char race='M';
int age = 21;
if ((race=='m') &&( age <=20)) then
cout<<"MARA LOAN";
else
cout<<"PTPTN LOAN";
4. What is the output of the following C++ code segment:-
char race;
int age;
cin>>race>>age;
if(race='m')
if(age<=20)
cout<<"MARA LOAN";
else
cout<<"PTPTN LOAN";
else
cout<<"OTHER LOAN";
a) When the user inputs "C" for race and 21 for age
b) When the user inputs "C" for race and 18 for age
c) When the user inputs "m" for race and 21 for age
d) When the user inputs "m" for race and 18 for age
5. Prepare an algorithm (pseudo code or flowchart) and write a C++ program for each of the following problem.
a) Write a program to find perimeter and area of a rectangle. The perimeter and area of the rectangle are given by the following formulas:
perimeter = 2 * (length + width)
area = length * width
b) Write a program to read user id and password .if the password is "abubakar" and password is 6855 then print out "Your password is accepted". Otherwise print "Not Accepted".
Assignment 1 BCT 1113. Sila download di sini.
Tugasan pertama ini akan menguji kemahiran ' problem solving ' pelajar dalam menyelesaikan masalah seharian.
Pelajar di minta menyediakan Algorithma (flowchart dan pesudoce) serta program C++ bagi setiap masalah yang di berikan.
Tarikh Hantar ialah pada : 17/2/2011.
'Viva' untuk setiap pelajar akan di buat selepas semua tugsan di terima.
1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan. ...