angleboy90 0 Report post Posted November 20, 2008 aku guna macam niechar grade;pastu utk if else guna macam nie plak CODEif(purata2 >= 80) {grade = 'A';} else if (purata2 >= 75) {grade = 'B+';} else if (purata2 >= 70) {grade = 'B';} else if (purata2 >= 65) {grade = 'C+';} else if (purata2 >= 50) {grade = 'C';} else if (purata2 >= 40) {grade = 'D';}else { grade = 'E';tapi utk output B+ dan lain2 yang ada simbol + dia kuar + jenape ekboleh tlg ? Quote Share this post Link to post Share on other sites
MatchMaker 0 Report post Posted November 20, 2008 (edited) Name : charDescription : Character or small integerSize : 1byteRangesigned: -128 to 127unsigned: 0 to 255sepatutnya IDE ko akan bagi warning macam ni.[Warning] multi-character character constant //aku guna Dev-C++meaning yang char hanya boleh receive 1byte je. so dalam kes ko nih, just dapat '+' instead of full 'B+' or 'C+'so cuba work around benda ni dengan include library macam string dalam program ko.CODE#include <iostream.h>#include <stdlib.h>#include <string.h>using namespace std;int main(){int purata2;purata2 = 76;string grade;if(purata2 >= 80) {grade = "A";} else if (purata2 >= 75) {grade = "B+";} else if (purata2 >= 70) {grade = "B";} else if (purata2 >= 65) {grade = "C+";} else if (purata2 >= 50) {grade = "C";} else if (purata2 >= 40) {grade = "D";}else { grade = "E";}cout<<"huuuuuuuuu "<<grade;system ("pause");return 0;}edit - additional explanation Edited November 20, 2008 by MatchMaker Quote Share this post Link to post Share on other sites
cikdayah 0 Report post Posted November 20, 2008 cikgu match maker sy xfhm Quote Share this post Link to post Share on other sites
DrASAG 0 Report post Posted November 20, 2008 char grade = 'AB' dia amik satu nilai jer. kalo ank amik AB tu leh wat string grade="AB". tak pun char grade[]="AB"... errr betul ke. hehehehe dah lma tinggai c nih.. Quote Share this post Link to post Share on other sites
cikdayah 0 Report post Posted November 20, 2008 bole ek cam2 kire letak kan sbgai array output die kuar as string.da lame gak xpegang c ni.asik dgn java jek Quote Share this post Link to post Share on other sites
angleboy90 0 Report post Posted November 30, 2008 okeh.. terima kasih semua yang membantu.. alhamdulillah kerja dah siap Quote Share this post Link to post Share on other sites