• Announcements

    • Peraturan Umum, Sila baca !

      1) Perbincangan illegal , seperti download , provide link muat turun, lanun sebagainya ditegah dan akan dipadam tanpa notis. Sila ambil perhatian , sebarang perbincangan mengenai download men-download, sharing link yang berkait kepada illegal material: - akan dipadam serta merta - tiada kompromi, user akan diberi warn jika melakukan kesalahan sama Contoh related : - " aku tengah sedut ni.. sejam lagi siap.. " - " kat mana ko dload laju gile.. aku lagi 14 hari nk siap" 2) Spamming, double pos, smiley semata-mata adalah satu kesalahan besar, elakkan membuat susulan pos dibawah susulan sendiri. Warning tanpa notis akan diberikan. 3) Elakkan drama fanboyism , samada berkait dengan konsol, permainan pc dan sebagainya 4) Perbincangan private server tidak dibenarkan, namun multiplayer via hamachi group dibenarkan. 5) Cheat codes dibenarkan, tetapi tidak kepada [email protected] 6) Screenshot seeloknya bersaiz 640 x 480 ke bawah, sila gunakan code spoiler sekiranya tidak resize pic anda. 7) One line posting (susulan satu baris) tanpa menjawab persoalan dan tidak memberi apa-apa manfaat dikira sebagai SPAM. SILA GUNAKAN FUNGSI REPORT JIKA TERDAPAT USER/TOPIK YANG MELANGGAR PERATURAN DI ATAS. ____________________________________________________________ _______________________________ .::. Kegagalan mematuhi terma dan syarat boleh mengakibatkan posting anda di padam dan anda mendapat warn level secara percuma .::. ____________________________________________________________ _______________________________
Sign in to follow this  
Followers 0

Coding Tentukan Gred

15 posts in this topic

Posted · Report post

LEH TLG BGI SIKIT CONTOH X NAK WAT SOKLAN NI...

menentukan gred yang tertinggi daripada 5 org pelajar...

Share this post


Link to post
Share on other sites

Posted (edited) · Report post

pakai if statement,

hint:

CODE
if (plajar1mark > plajar2mark) and (pljar1mark > plajar3mark) and (pljar1mark > plajar4mark) and (pljar1mark > plajar5mark)
    { cout >> plajar1mark+" highest" }
else if (plajar2mark > plajar1mark) and (pljar2mark > plajar3mark) and (pljar2mark > plajar4mark) and (pljar2mark > plajar5mark)
    { cout >> plajar2mark+" highest" }
else if (plajar3mark > plajar1mark) and (pljar3mark > plajar2mark) and (pljar3mark > plajar4mark) and (pljar3mark > plajar5mark)            
    { cout >> plajar3mark+" highest" }
    .
    .
    .
end if


actually code ni bukan code utk c++ tp aku terjemahkan bahasa aku sendiri. aku bagi gambaran je. n code ni xkn dpt jwpn gak kalo markah sama. hehe.. sbb ni pc aku tgh hang. pake laptop org je..

P/s: tukarkan code ne ke C++, ang blaja kan..so mest dpt gambaran dah. pastu yg dot dot dot tu..sambung la sampe dari plajar4mark ke plajar5mark. command c++ aku dah xigt..so maafkn aku syntax tunggang tbalik. kirh2.. laugh.gif Edited by yurckk

Share this post


Link to post
Share on other sites

Posted · Report post

QUOTE(ezora @ Nov 5 2008, 11:07 AM) <{POST_SNAPBACK}>
LEH TLG BGI SIKIT CONTOH X NAK WAT SOKLAN ASSIGNMENT NI...

menentukan gred yang tertinggi daripada 5 org pelajar...


aku dah betulkan sikit ayat kat atas tu

QUOTE(yurckk @ Nov 5 2008, 01:39 PM) <{POST_SNAPBACK}>
pakai if statement,

hint:

CODE
if (plajar1mark > plajar2mark) and (pljar1mark > plajar3mark) and (pljar1mark > plajar4mark) and (pljar1mark > plajar5mark)
    { cout >> plajar1mark+" highest" }
else if (plajar2mark > plajar1mark) and (pljar2mark > plajar3mark) and (pljar2mark > plajar4mark) and (pljar2mark > plajar5mark)
    { cout >> plajar2mark+" highest" }
else if (plajar3mark > plajar1mark) and (pljar3mark > plajar2mark) and (pljar3mark > plajar4mark) and (pljar3mark > plajar5mark)            
    { cout >> plajar3mark+" highest" }
    .
    .
    .
end if


actually code ni bukan code utk c++ tp aku terjemahkan bahasa aku sendiri. aku bagi gambaran je. n code ni xkn dpt jwpn gak kalo markah sama. hehe.. sbb ni pc aku tgh hang. pake laptop org je..

P/s: tukarkan code ne ke C++, ang blaja kan..so mest dpt gambaran dah. pastu yg dot dot dot tu..sambung la sampe dari plajar4mark ke plajar5mark. command c++ aku dah xigt..so maafkn aku syntax tunggang tbalik. kirh2.. laugh.gif


kenapa tak guna for loop je?

CODE
double markahTertinggi = 0; //assuming markah takkan kurang dari 0
double markahPelajar[5];

markahPelajar[0] = 54;
markahPelajar[1] = 61;
markahPelajar[2] = 23;
markahPelajar[3] = 73;
markahPelajar[4] = 54;

for (int i = 0; i < 5; i++){
   if (markahPelajar[i] > markahTertinggi){
      markahTertinggi = markahPelajar[i];
   }
}

return markahTertinggi;

Share this post


Link to post
Share on other sites

Posted · Report post

QUOTE(MatchMaker @ Nov 5 2008, 02:24 PM) <{POST_SNAPBACK}>
aku dah betulkan sikit ayat kat atas tu



kenapa tak guna for loop je?

CODE
double markahTertinggi = 0; //assuming markah takkan kurang dari 0
double markahPelajar[5];

markahPelajar[0] = 54;
markahPelajar[1] = 61;
markahPelajar[2] = 23;
markahPelajar[3] = 73;
markahPelajar[4] = 54;

for (int i = 0; i < 5; i++){
   if (markahPelajar[i] > markahTertinggi){
      markahTertinggi = markahPelajar[i];
   }
}

return markahTertinggi;


btol2.. pake loop sng. aku dah lm tggl programming..basic pon dah out..tp skrg aku walopon jd tech je..kne gak wat keje programmer huh.gif

so kt cne nk pake if ke nk pake loop ke..ikut le..senang yerk wat assignment.. tongue.gif

Share this post


Link to post
Share on other sites

Posted · Report post

sush la da wat tp xpat jgk...da cbe sume care 2 tp xpat pon...maklumla sy ni bru sijil je...so x pandai sgt r...
bg yang simple je leh x?plz....

Share this post


Link to post
Share on other sites

Posted · Report post

lor.. tu dah abih simple le tu... kalo ko copy paste bulat2, mmg tak jadik ar..... uik tak kisahla sijil ker apa ker, ko dah ada basic kan.... kena cuba arrr..

**try and always error.... huhuhu

Share this post


Link to post
Share on other sites

Posted · Report post

ok ni yang aq da wat...tp slh gak...
#include<iostream.h>
void main(){

char plajar1mark,plajar2mark,plajar3mark,plajar4mark,plajar5mark;

if (plajar1mark > plajar2mark){
if (plajar1mark > plajar3mark) {
if(plajar1mark > plajar4mark){
if (plajar1mark > plajar5mark) {
cout <<"\n pelajar 1 gred tinggi";
}
}
}
}

else if (plajar2mark > plajar1mark) {
if (plajar2mark > plajar3mark){
if(plajar2mark > plajar4mark){
if (plajar2mark > plajar5mark){
cout<<"\n pelajar 2 gred tinggi";
}
}
}
}

else if (plajar3mark > plajar1mark)
if (plajar3mark > plajar2mark) {
if (plajar3mark > plajar4mark){
if (plajar3mark > plajar5mark) {
cout<<"\n pelajar 3 gred tinggi";



else if (plajar4mark > plajar1mark) {
if (plajar4mark > plajar2mark) {
if (plajar4mark > plajar3mark){
if (plajar4mark > plajar5mark) {
cout<<"\n pelajar 4 gred tinggi";
}
}
}
}

else if (plajar5mark > plajar1mark)
if (plajar5mark > plajar2mark) {
if (plajar5mark > plajar3mark){
if (plajar5mark > plajar4mark) {
cout<<"\n pelajar 4 gred tinggi";
}
}
}
}
}
}


}

Share this post


Link to post
Share on other sites

Posted (edited) · Report post

klas dah start blaja pakai for loop x?
kalo dah pake yg MatchMaker kasik tu. Kalo takat blaja if statement je guna aku nyer.
tp aku nyer tu bhs programming aku sniri. so convert la ke c++ Edited by yurckk

Share this post


Link to post
Share on other sites

Posted (edited) · Report post

number bukan char, so kenapa nak declare char plajar1mark,plajar2mark,plajar3mark,plajar4mark,plajar5mark;
patut guna number data type, contoh mcm int or double.

nak buat if else statement camtu pun ok, sebab dah tau limit ko nyer input just 5.
emmm mana part nak masukkan/input data tu?

patut ada coding macam plajar1mark = 51;
or cin>>lajar1mark;
pastu baru boleh buat if else tu.

lagi satu, ko guna void main() ni, programming ni dalam C ke?
apa pun ko perkemaskan dulu apa yang yurckk bagi.
jgn risau, kitorang ada and akan tolong saudari biggrin.gif .

@yurckk - ehehe sorry aku tak perasan gak, maybe dia taktau pun camna nak guna for loop pada tahap ni. Edited by MatchMaker

Share this post


Link to post
Share on other sites

Posted (edited) · Report post

yerp...char is stand for character..meaning to say

char = 'a'; sbg cth

yerp ikut jugak post atas ne by "MatchMaker" where kne ade initialization utk each variable kne ade nilai.

so smada program dah set sniri or tgu pengguna masukkan:

cth sm ngn "MatchMaker" wat kt atas ne..

btw recheck balik blaja C ke C++, jgn salah...de kes org dah dkt exam baru tau yg die blaja C bkn C++ smile.gif

@Matchmaker : aku no hal, xpe..at least die da nmpk flow utk for loop laugh.gif Edited by yurckk

Share this post


Link to post
Share on other sites

Posted (edited) · Report post

cuba tgok coding ni... ianya untuk identify the highest value guna loop..

aku dah lama tinggal c plus2 ni.. so aku kerat2 je dr file simpanan.. k

CODE
//identify highest value using for looping... berjaya

#include <iostream.h>

main()
{
  int counter;
  int value;
  int highest;

  highest = 0;
  value = 0;


  for (counter = 0; counter < 5; counter++)
  {

  cout << "enter a value : ";
  cin >> value;
     if (value > highest)
        highest = value;

  }

  cout << endl;
  cout << "The highest value is : " << highest << endl;

  return 0;
}



===============================================

// loop for low n high value

#include <iostream.h>

main()
{
  int x, high, score, low;

  score = 0;
  x = 0;
  high = 0;
  low = 100;

  while(x < 5)
  {
  x++;

  cout << "Enter Score : ";
  cin >> score;

  if ((score != 0) && (score < low))
     low = score;
  else if (score > high)
     high = score;
  }

  cout << endl;
  cout << "the highest value is " << high << endl;
  cout << "the lowest value is " << low << endl;
  return 0;
}
Edited by Nazi370

Share this post


Link to post
Share on other sites

Posted · Report post

pakai if terlalu complicated aku tgk, apa kata pkai if else if tgk.. rasanya lagi tersusun

Share this post


Link to post
Share on other sites

Posted · Report post

dah berjaya ke buat, kalau x berjaya saya tlg buat

Share this post


Link to post
Share on other sites

Posted (edited) · Report post

kalu gne if else kan lg senang..
off topic sat..
aku skang mmg pning dgn OOP..
sbb aku spoil kat function..
bleh sape2 ajorkan x? Edited by azrul0999

Share this post


Link to post
Share on other sites

Posted · Report post

QUOTE(azrul0999 @ Nov 14 2008, 02:02 PM) <{POST_SNAPBACK}>
kalu gne if else kan lg senang..
off topic sat..
aku skang mmg pning dgn OOP..
sbb aku spoil kat function..
bleh sape2 ajorkan x?


saya leh, pm kat [email protected]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0