2/27/2011

DCT1063 Programming 2

ASSIGNMENT 2


 

  1. Explain the purpose of following function.


     

No 

Function

Purpose 

0 

strcpy 

Copies the string pointed by source into the array pointed by destination, including the terminating null character.

1 

strlen 

 

2 

strcmp 

 

3 

strcpy 

 

4 

strncpy 

 

5 

strcat 

 

6 

isalnum 

 

7 

islower 

 

8 

isspace 

 

9 

tolower 

 

10 

toupper 

 


 


 


 

  1. Write a program that reads one line of text and then prints it with all letters capitalized.


 

Input:        Abu Bakar

Output:    ABU BAKAR


 

3.     Write a program that separately inputs a first name and a last name and concatenates the two into a new string.


 

4. Write a program that reads one line of text and then prints the text in reverse order. For example, the input

today is tuesday

Would produce the output

yadseut si yadot


 

5.    Write a program that reads one line of text and then prints it with all its 'a','e', 'i', 'o', 'u','A','E', 'I', 'O', 'U' removed.

For example:

Input:        A structure (struct) type is a user defined composite type.

Output:    strctur (strct) typ is sr dfnd cmpsit typ.


 


 

6.     Write a program that counts the total number of vowels in a sentence. Output the frequency of each vowel.

For example:

Input:        A structure (struct) type is a user defined composite type.

Output:    A    :    2

        E    :    5

        I    :    3

        O    :    1

        U    :    4


 

7.    Write a program that reads one line of text and then prints the numbers of four-letter words that were read.


 

Input:        A structure (struct) type is a user defined composite type.

Output:    Number of words with four letter =3.


 


 


 


 

BCS1333 CPU Scheduling Exercise

Note Chapter 5 : CPU Scheduling Willey

TRUE/FALSE

  1. Process execution begins with a CPU burst. That is followed by an an I/O burst, which is followed by another CPU burst, then another I/O burst, and so on. [ T / F ]
  2. CPU scheduling is the task of selecting a waiting process from the ready queue and allocating the CPU to it.[ T / F ]
  3. The Final CPU burst ends with a system request to terminate execution.[ T / F ]
  4. The simplest CPU-scheduling algorithm is first-come, first-served.[ T / F ]
  5. Implementing Short Job First (SJF) scheduling is difficult because predicting the length of the next CPU burst is difficult.[ T / F ]
  6. Both priority and SJF scheduling may suffer from starvation.[ T / F ]
  7. Aging is the technique to prevent starvation.[ T / F ]
  8. Round-Robin (RR) is similar to FCFS except it has time quantum.[ T / F ]
  9. The average waiting time under the Round-Robin is often long.[ T / F ]
  10. THE FCFS algorithm is nonpreemptive; the RR is preemptive. [ T / F ]

SHORT ANSWER

  1. There a re five (5) criterion that have been suggested for comparing CPU scheduling algorithms. List and briefly explain each of them.

    ________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

  2. Consider the following set of processes that arrive at time 0, with the length of the CPU burst given in miliseconds:


Process Burst Time Priority

P1 15 3

P2 10 1

P3 3 3

P4 5 2

The processes are assumed to have arrives in order P1,P2,P3,P4 all at time 0.

  1. Draw four Gantt ccharts that illustrate the execution of these processes using the following scheduling algorithms : FCFS, SJF, nonpreemptivr priority ( a smaller priority number implies a higher priority), and RR (quantum = 3).

    ________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________


  2. What is the waiting time of each process of the scheduling algorithms in part a?

    ________________________________________________________________________________________________________________________________________________________________


  3. What is the turnaround time of each process of the scheduling algorithms in part a?

    ________________________________________________________________________________________________________________________________________________________________


  4. Which of the algorithms in part a results in the minimum average waiting time (over all processes)?

    ________________________________________________________________________________________________________________________________________________________________


  1. In priority scheduling, priorities can be defined either internally or externally. Briefly explain what is internal priorities and what is external priorities.

    ________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________


  1. What is major problem with priority scheduling and what is the solution?

    ________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________



2/23/2011

BCT1113 CP lab 24/2/2011


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;

}

2/19/2011

DCT1063 P2 PRE-TEST

A

The &
operator will returns the memory
address of its operand.

T/F

B 

The * operator
will returns the value of the variable located at the address specified by its operand.

T/F

C 

In C++, there is a close relationship between pointers and arrays.

T/F

D 

Consider the following fragment:

int no[3]={0,1,2};

int *p1;

p1 = no;

the statement no[1] or *(p1+1) will output the different result.

T/F

E 

Both statements (in D) will return the 1st element of array no .

T/F

F 

In order to perform file I/O, you must include the header <string.h>
in your program.

T/F

G 

To open an output stream, you must declare the stream to be of class ofstream.

T/F

H 

A stream that will be performing both input and output operations must be declared as class ifstream.

T/F

I 

The following fragment opens a file called out;

ofstream out;

out.open("test.txt");

T/F

J 

To close a file, use the member function close( ).

T/F


 

SECTION B –Show Output

1. What is output by the following program segment?


 

1 int number = 9;

2 int *p = &number; // address of number is 0010FF8C

3

4cout << number << " " << *p << " " << p;

(4 Marks)

answer


 


 


 


 


 

2. What is output by the following program segment?


 

1 int a[] = { 1, 3, 5, 7, 9 };

2 int *p = a;

3

4 cout << a[ 0 ] << " " << *( p + 1 ) << " " << p[ 2 ];

(4 Marks)


 

answer:


 


 


 


 

3. What is output by the following program segment?


 

1 int a[] = { 1, 2, 3, 4, 5 };

2 int *p = a;

3

4 cout << a[ 0 ];

5 cout << *(a+1);

6 cout << *(p + 2);

7 cout << p[ 3 ];

(5 Marks)


 

answer:


 


 


 


 


 


 


 


 

4. What is output by the following program segment?


 

1 int i,a[] = { 1, 2};// address of a[0] is 5000

2 int *p = a;

3

4 for(i=0;i<=1;i++)

5

6 cout << (p+i)<<" "<<*(p+i)<<endl;

(3 Marks)


 

answer


 


 


 

SECTION C –Programming



 

  1. Consider the following C++ program. Show the content of test.txt


    #include <iostream>

    #include <fstream>

    using namespace std;

    int main()

    {

    ofstream out("test.txt");

    out << 10 << " " << 123.23 << "\n";

    out << "This is a short text file.";

    out.close();

    return 0;

    }


 


 


 

2. Write a program that prompts user to enter:-


 

  1. Name
  2. Age
  3. State
  4. Country


 

and write into a file named biodata.txt as follows.


 

Name     : Ahmad Ashraaf

Age    : 19

State: terengganu

Country: Malaysia


 


 


 

(10 Marks)

2/12/2011

QUIZ 2 BCS1333

Chapter 4 : Threads


 

1. What is thread (in Operating Systems)? (3 marks)

2. The benefits of multithreaded programming can be broken down into four major categories. List all of them. (4 marks)

3. There are two level of threads; user thread and kernel thread. Briefly explain what is user thread and kernel thread. (4 marks)

4. Draw a figure to illustrate the three model of Multithreading (Many to one, one to one and many to many). (4 marks)


 

Click here to download chapter 4 lectures slide.

Due date 14 feb 2011. 830 am (during lab session).

Note: Solution for questions 1, 2, and 4 can be found on the given slide. Please google (search on internet) for question 3.

2/11/2011

ELAK SAMBUT VALENTINE’S DAY (MUSLIM)


"Dalam hal ini Panel Kajian Aqidah (PKA) dan Panel Kajian Syariah (PKS) Jabatan
Kemajuan Islam Malaysia (JAKIM) telah memutuskan bahawa “Amalan
menyambut Hari Valentine’s Day adalah haram dan bertentangan
dengan ajaran Islam”. Manakala Jawatankuasa Fatwa Majlis
Kebangsaan Bagi Hal Ehwal Agama Islam Malaysia kali ke-71 yang
bersidang pada 22 hingga 24 November 2005 memutuskan: “Bahawa
amalan merayakan Valentine’s Day tidak pernah dianjurkan oleh Islam.
Roh perayaan tersebut mempunyai unsur-unsur Kristian dan
amalannya yang bercampur dengan perbuatan maksiat adalah
bercanggah dan dilarang oleh Islam. Oleh itu amalan meraikan Hari
Kekasih tidak digalakkan oleh agama Islam”.

Untuk tulisan penuh - sila klik pada pautan ini.

2/10/2011

Cara padam/ganti file dalam system32


Dalam sesetengah keadaan (contohnya untuk crack software!), beberapa fail dalam folder C:\windows\system32 perlu di ganti secara manual. Biasanya ia melibatkan fail *.dll (dll ialah file yang diperlukan oleh lebih dari satu program dalam satu masa yang sama).

Dalam keadaan biasa-proses tersebut (padam/ganti fail) tidak dapat di lakukan kerana 'protection' daripada windows (terutamanya untuk vista dan windows 7).

Dua artikel berikut menerangkan satu kaedah mudah bagi melakukan perkara tersebut.

How To: Replace/Delete Protected DLL Files In Windows 7 & Vista

How To: Take Ownership Of A Folder/File In Windows 7

2/08/2011

BCT1113 Test 1 (sample)-SOLUTION

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 (T)

b) Compiler: translates a program written in a high-level language into machine language (T)

c) Preprocessor directives begin with # and are processed by a the preprocessor (T)

d) Use the compiler to: Check that the program obeys the rules (T)

e) Linker: Combines object program with other programs provided by the SDK to create executable code (T)

f) Programming is a process of problem solving (T)

g) Algorithm: Step-by-step problem-solving process (T)

h) Two popular approaches to programming design: - 1) Structured 2) Object-oriented (T)

i) The structured design approach is also called Modular Design (T)


 

2. Print the output of the following C++ statement. If nothing prints, then answer "nothing". Assume x=3 and y=2.

Example) cout<<x;            3


 

a) cout<<y;            2

b) / * cout<<y; */        nothing

c) // cout<<x+y;        nothing

d) cout<<x<<y;        32

e) cout<<x<<endl<<y;

3

2

f) cout<<x+y;            5

g) cout<<"x+y="<<x+y;    x+y=5

h) cin>>x%y;            1

i) cout<<++x;            4

j) cout<<y++;            2


 

3. Print the output of the following C++ statement. If nothing prints, then answer "nothing".


 

a)     if(1<3)

cout<<"Yes";

else

cout<<"No";

yes

b)     char race='M';

if ((race=='m') ||( race =='M')) then

cout<<"Malay";

else

cout<<"Others";

    Malay

c)      char race='M';

     int age = 21;

if ((race=='m') &&( age <=20)) then

cout<<"MARA LOAN";

else

cout<<"PTPTN LOAN";

    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";


 

  1. When the user inputs "C" for race and 21 for age

    OTHER LOAN


     

b) When the user inputs "C" for race and 18 for age

OTHER LOAN

  1. When the user inputs "m" for race and 21 for age

    PTPTN


     

d) When the user inputs "m" for race and 18 for age

MARA LOAN


 

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".

InsyaAllah Versi Melayu


Maher Zain - adalah seorang penyanyi Sweden dan penerbit muzik yang berasal dari Lubnan. Video (lagu) beliau di laman Youtube telah mengumpul lebih dari 5 juta hit. Antara lagunya yang menjadi minat (saya) adalah Barakallah dan InsyaAllah. Beliau telah menerbitkan lagi InsyaAllah versi melayu. Link untuk lagu tersebut boleh di dapati dari pautan berikut:-
1. http://www.4shared.com (format mp3)
2. youtube (format mp4)

Liriknya

Andainya kau rasa tak berupaya
Hidup sendirian tiada pembela
Segalanya suram
Bagai malam yang kelam
Tiada bantuan tiada tujuan
Janganlah berputus asa
Kerana Allah bersamamu


Chorus
Insya Allah Insya Allah Insya Allah
Ada jalannya
Insya Allah Insya Allah Insya Allah
Ada jalannya

Andainya dosamu berulang lagi
Bagai tiada ruang untuk kembali
Dikau keliru atas kesilapan lalu
Membelenggu hati dan fikiranmu
Janganlah berputus asa
Kerana Allah bersamamu

Ulang Chorus

Kembalilah
Kepada Yang Esa
Yakin padaNya
Panjatkanlah doa
Oh Ya Allah
Pimpinlah daku dari tersasar
Tunjukkan daku ke jalan yang benar
Jalan yang benar
Jalan yang benar
Jalan yang benar

2/06/2011

BCS 1333 OS TEST 1 Preparation

  1. What is Operating Systems? (3 marks)


  2. Why do computer need Operating Systems? (3 marks)


  3. Give 4 examples of OS available on the market. (4 marks)


  4. Draw the layers of a computer system (complete a given figure) ( 4 marks)


    <<will be update later>>

  5. Briefly explain the process of booting. (5 marks)



  6. What is the purpose of system calls? (2marks)


  7. Give five (5) types of system calls.

(5 marks)

  1. Explain three (3) types of process states.

    (6 marks)

  2. Give five (5) services provided be OS for process management.

    (5 marks)


  3. Why we cannot store the programs and data in main memory permanently?

    (4 marks)


Cara download Installer windows 10 dalam format ISO

1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan.  ...