SPIES BERDAFTAR

28 December 2015

weekly reminder #1

بسم الله الرحمن الرحيم

Almighty. Keep reminding me that  
the blessings in my life are due to 
your Mercy & not my actions. 
When I get proud, give me a wake  
up call.


Mufti Menk, 27th Dec 2015 on twitter

regards,

03 November 2015

programming tips #1 : conditional expression (for c & c++)

ASSALAMMUALAIKUM W.B.T. peeps !

frankly, i'm inspired to share this on my blog bcoz on this evening, i got programming test and.... i'm stucked at this question. lol! never expect this one to be questioned on test... T.T k, my bad..


after finishing the test & went back to my room, i started to do some coding bout it to understand more. and now here i am, wanting to share to you all what i got.

so, first of all. what is conditional expression?  well, it is an expression that use conditional operators.

conditional operators are basically  ? and : symbols.

what are they used for? 
they are used to simplify or shorten if...else statement.

how?
here's the syntax >>
condition ? true case : false case

comparing it with an if..else statement;

if(condition)
   true case;
else
   false case;


got it? yes? congrats, fast-learner!

no? it's ok, let's move on with a simple example..

suppose there's a if...else statement;

if(marks>50)
   pass++; //increase number of student passed by 1
else
   fail++; //increase number of student failed by 1

converting this using conditional expression;
marks>50 ? pass++ : fail++ ;

condition before the ? will be tested. if true, execute pass++ (statement between ? and :). else, execute fail++ (statement after :) .


next example.. printing output.
from;

if(weight>65)
   cout<<"Fat!!"; 
else
   cout<<"Gorgeous!"; 

from what we had learnt before, converting this using conditional expression;
weight>65 ? cout<<"Fat!!" : cout<<"Gorgeous!" ;

but! there's a simpler way of doing this;
cout<<(weight>65 ? "Fat!!" : "Gorgeous!") ;

note that the second way we need to put brackets so the compiler will give priority to the conditional expression first.

same goes in c language;
from;

if(weight>65)
   printf("Fat!!"); 
else
   printf("Gorgeous!");

converting to conditional expression;
mark>50 ? printf("PASS") : printf("FAIL"); 

or putting the conditional expression inside printf;
printf(mark>50 ? "PASS" : "FAIL");

note that for the second way we did not need to put extra bracket (comparing to c++). bracket from the printf is enough.


all of examples above are the simple ones. of course, those that went out in my exam earlier is much more complicated. ~.~

such as (using c++):

if(cpa>3.0)
{
   if (cpa>3.5)
      cout<<"Dean's List";
   else
      cout<<"Second Class";
}
else
{
    if(cpa>2.0)
       cout<<"Passed";
    else
       cout<<"Failed!"; 
}

converting to conditional expression;
cout<<(cpa>3.0?cpa>3.5?"Dean's List":"Second Class":cpa>2.0?"Passed":"Failed");

if you compare both thoroughly, you can see that is just follow the flow as the if....else statement. line by line. and this is the example for nested if...else.


last example,
(using c language);

if(height>170)
{
   printf("So tall!") ; 
   tallpeople++ ; //increase number of tall people by 1
}
else
{
   printf("Hi shorty.") ;
   shortpeople++ ; //increase number of short people by 1
}

converting to conditional expression;
height>170 ? printf("So tall!") , tallpeople++ : printf("Hi shorty.") , shortpeople++ ;

or

printf(mark>50 ? "So tall!",tallpeople++ : "Hi shorty.",shortpeople++);

this example is actually for if...else with compound statements. we just need to put comma ',' between these statements.

final note, spaces between conditional operators are not necessary, but it'll make your coding easier to read.. as malay words, "sedap mata memandang" :3


that's all for tonight. hope this helps to enhance your knowledge. ^^


till we meet again!
regards,

28 October 2015

c++ programming source code sharing #1 : CALCULATE API VALUE (my midterm exam's answer)

ASSALAMMUALAIKUM W.B.T. peeps !


So today, I would like to share with you all, my midterm exam's question and sample answer. The answer for this question is not yet discussed in class, so the one I share here is the one I wrote during the exam, with some modification was done later. oh yeah, i'm using Dev-C++ ver 5.11 IDE.

even though haze prob is almost nil right now in Skudai, all thanks to Allah for these past 1-2 days heavy rain.. it's still not a crime to post some haze-related coding, rite? :v

INSTRUCTIONS:
Write a C++ program to calculate the accurate API value and determine the status of the air quality.
The program should perform the following steps:

a. Ask the user to enter the number of locations that will be read from an input file (maximum
number of location is 10). Example runs of the program are shown in Figures 1(a), 2(a) and
3(a). Note: The bold texts in Figures 1(a), 2(a) and 3(a) indicate input from the user.

b. Read input data, location and the pollutant value of PM2.5 from the input file named
input.txt”. The number of input data that will be read from the file is based on the number
of locations entered in (a). An example of the series of input data in the input file is shown in
Figure 4.

c. Calculate the API value using the formula given.

d. Based on the API value calculated; determine the air quality status.

e. Calculate the number of stars that represent API value. Each star (the character '*') represents
twenty (20) API value.

f. Calculate the average of API value.

g. Find the highest and lowest API value.

h. The output of this program should be displayed into the output file named “output.txt”. The
snapshots of the output file are as shown in Figures 1(b), 2(b) and 3(b). Display the output
telling the following information:
i. The location
ii. The calculated API value
iii. The corresponding air quality status
iv. Display a bar chart (using stars) for the API value. Each star (the character '*')
represents twenty (20) API value.
v. The highest API value
vi. The lowest API value
vii. The average API value


***I also add some extra coding in my source code that is to check the validity of number of location entered. if number entered is negative or more than 10, error message will appear and user need to enter another number. also, i add a prompt message at the end of the program where it tells the user to refer to output.txt file for the report. :3

below are figures from my question paper:
formula & status







and here's the screenshot of my code :

****I changed the output file name a bit coz this is my modified version of coding and I want to compare with the original one.

Some of the code is not seen clearly due to the loooong line. maybe you can figure out the 'hidden' code by yourself or if you need, you can download the source file. link is at the end of this post.

**depending on your IDE version, you may not see the prompt message I mentioned earlier. if that's the case, you need to add system("pause"); at the end of your main function.


Here's the output.txt screenshot for 10 inputs:





that's all for now. till we meet again. adios! ;)

regards,

15 October 2015

personal blog #9 - brief update

ASSALAMMUALAIKUM W.B.T. peeps !

ni hao guyssss. just a short update, I'm currently a first year student of software engineering at UTM. some may argue it's not the best decision, while others support me. above of all, I'll just try to do my very best here, insyaAllah!

sooooo, for the first sem here, I'm learning c++, thus will be sharing some later on. already got one reserved actually. but can't really promise when to share coz of my busy schedule and lazy to write. hehe.
some sneak peek 

anyway, I'm currently working on a line following robot, using microcontroller, IR sensors and motor driver L293D. it's for UTM's Robocon Recruitment Minigame. currently stuck at programming part as it is walao~ even it's basically c language based, i still struggling to understand coz it's somewhat not THAT easy as what i learnt during foundation ~.~

last but not least, do pray my project will be a success thus i may share with you guyss (like, is there anyone reading this? lol). whatever. sayonara. oh, and salam awal muharram. :3
regards,

05 August 2015

c programming source code sharing #7 : TENNIS SCOREKEEPER

ASSALAMMUALAIKUM W.B.T. peeps !

heyya guys! i've promised wayyyy loooong before that i'll be sharing my computing II assignment source code soon. lol. pardon me. just, being a potato.....is so much 'fun'. *troll face*

so, without further adieu. this is it, TENNIS SCOREKEEPER.


CLICK THE IMAGE TO ENLARGE


the algorithm of the program :
1)Start.
2)Enter team's name or default.
3)Enter number of sets to be played.
4)Enter number of game per set to be played.
5)Enter the score. (Deuce, Tiebreaker are available if applicable).
6)Display the score.
7)Decide the winner.
8)End.

the source code is kinda loooong, so i just put some screenshots of it. for the full source code;
CLICK HERE

bye!
regards,

25 June 2015

MENFITNAH SEMUDAH ABC!

ASSALAMMUALAIKUM W.B.T. peeps !

Zaman moden ni, senang gila la nak fitnah orang! cuma perlu ada komputer, pelayar internet & sambungan internet. silap haribulan budak tadika pun boleh buat. macam mana caranya? meh ikut steps yang aku tunjuk dalam gambar2 di bawah.. & korang akan sedar betapa mudahnya menfitnah berserta bukti, *kononnya!


Wahai orang-orang Yang beriman! jika datang kepada kamu seorang fasik membawa sesuatu berita, maka selidikilah (untuk menentukan) kebenarannya, supaya kamu tidak menimpakan sesuatu kaum Dengan perkara Yang tidak diingini - Dengan sebab kejahilan kamu (mengenainya) - sehingga menjadikan kamu menyesali apa Yang kamu telah lakukan. 
Surah Al-Hujurat Ayat 6.

















Sesungguhnya orang-orang yang mendatangkan fitnah kepada orang-orang mukmin laki-laki dan perempuan, kemudian mereka tidak bertaubat, maka bagi mereka azab jahannam dan bagi mereka azab (neraka) yang sangat pedih.
(Q.S. al-Buruj: 10)





NOTA KAKI: TUJUAN AKU BERKONGSI NI BUKAN NAK MENGGALAKKAN ORANG MENFITNAH, TAPI NAK SEDARKAN BETAPA MUDAHNYA DOSA BESAR NI BOLEH DIBUAT. MOGA2 SELEPAS INI KITA SELIDIK DAHULU "BERITA TERKINI" YANG KITA TERIMA SAMA ADA SAHIH ATAU TIDAK SEBELUM TEKAN 'SHARE', MENJADI KEYBOARD WARRIOR, WAIMA JADIKAN BAHAN SEMBANG DI KEDAI KOPI.

wallahua'lam. semoga Allah redha!

regards,

16 April 2015

personal blog #8 : lessons learnt

ASSALAMMUALAIKUM W.B.T. peeps !


from my previous presentation of our programming project, i've come to a huge lesson for future and others :

GO FOR QUALITY INSTEAD OF QUANTITY

regards,

12 March 2015

personal blog #7 : done!!

ASSALAMMUALAIKUM W.B.T. peeps !

alhamdulillah, at last. at last. at laaast, i finished my final programming project. 15 types of sports score keepers all together. at first i made each of them in different c file, then after combining all of them... 2.1k lines in total! what a number! :3 yeahh, of course with some blank lines between those codes. hehe. at first we planned to make 25 types, then shorten to 20, and then 15..at last. kih kih. got no time to make that much, maybe(?). btw if.. i do make that much, that's mean my whole program will consist about..(takes calculator..calculating 2.1k/15*25)... 3.5k?! hah, kinda insanee. it's ok, daijou bu! 2.1k already enough & appropriate for my level i think.. hehe

soo, all these score keepers, if Allah wills, i will share in my blog once i'm over with my final exam here. or if i do find some time to update, i'll do it, one at a time. ;)

oh, i'm also planning to share inventory item updater source code! ← my csc individual assignment.
maybe in near future, potassium? :3

today is the last time i'm wearing lab coat here, in uitm palam


***update:my groupmate's coding is 8k lines! omo, i felt soooo down to earth. huhu

regards,

08 March 2015

personal blog #6; langkah panjang

ASSALAMMUALAIKUM W.B.T. peeps !

second time naik komuter. first time masa kecik2 dulu..

semua pakat order plain water.. kami ja yg.... *smbung ayat sendiri*

#spotd ; sweetest photo of the day

fitri koi keding bakhiang. aku xtau dia makan apa. 

w/ some of warga valiant generation yg turun. tudung pink; asma farhana, rainbow: afifah idris, coklat: arifah.
yang blueblack blkg tu xpayah intro kot. kuikui.
makcik ni la. asai plan nak turun mid kami dua ja. tup2 haritu gak VG nk buat gathering.
well, kills 2 birds w/ 1 stone la kira.

aku tak tau la. aku nak update blog pasal benda ni, tapi xreti pulak nak karang ayat panjang panjang cam dulu2. skill dah berkarat kot, maklumlah la ni orang tgh sibuk karang ayat dalam c language jaa. if you know what i mean. haha. padahal banyak ja benda awesome. so, share gmbaq ja la noh.
regards,

06 March 2015

personal blog #5

ASSALAMMUALAIKUM W.B.T. peeps !

jumaah barakah to all muslims. nothing much to say, just feel to post this photo as prove in future I was once a UiTM student & wearing lab coat is just awesome. :3


nota kaki: dah nak habis foundation.. tapi misi aku nak interview beberapa lecturer best tak jadi lecturer masih tak kesampaian...tak da masa yg sesuai...ceh.. sebenarnya hang tu yg pemalu x tentu pasai aiman oi!

regards,

03 March 2015

personal blog #4

ASSALAMMUALAIKUM W.B.T. peeps !

now is near the end. the climax. of being an UiTM Foundation student. 2 weeks left till csc presentation & test 2. 3 weeks left till final exam. time for the last sprint. will i manage to cross the finishing line or will i 'pancit' near the end?

regards,

17 February 2015

personal blog #3 : rugi?

ASSALAMMUALAIKUM W.B.T. peeps !


rugi ke?
aku minat.

dah. aku. minat.

macam nak jadi programmer @ software engineer.
tapi.
lecturer pun cam best.
nak iv para lecturer best x jd lecturer.
tapi maluuu.
:3

pepun.
yg pasti.
aku nak sambung degree.
sbb nak ilmu.
nk lebih mendalami ilmuNya.
kerja pikiaq len.


boleh lgutu?

regards,

10 February 2015

c programming source code sharing #6 : Printing a hollow square using nested for

ASSALAMMUALAIKUM W.B.T. peeps !

hi hi hi. (greeting ni, "hai hai hai" bukan gelak hi hi hi)
so today i would like to share the next source code, of my homework this week, freshly from oven!
*baru siap buat daa*

sample question:
Read an integer(entered by user) and prints a hollow square. the number of '=' used to draw line of each sides of square.

example, user enter 5, so the output is
=====
=      =
=      =
=      =
=====
a 5x5 square with a hollow.(hollow-lubang)
(not-so-square looking here, but in .exe file you'll see it is more like a square!)

another sample output:


of course, it will only works with positive integers.
& for integer=1 & 2, you'll not see a hollow.

soooo here's the screenshot of my source code:

CLICK IMAGE TO ENLARGE

or, download the c-file here. (can edit&try compile yourself!)

my lecturer told us, usually for this kind of question, there would be more than 1 solution. so my fellas out there, if you have a simpler & more unique way, please share! sharing is caring yow! & for any questions, please, just ask me ok? :)

regards,

02 February 2015

my group project assignment

ASSALAMMUALAIKUM W.B.T. peeps !

hi. just wanna tell you guys i'm doing sports score keeper (yep, with 's' coz more than 1 sport). for my Foundation in Computing II subject group project assignment. there'll will be basketball, futsal, netball & so on if Allah wills. Currently when i'm writing this i only finished Basketball Score Keeper & working on Futsal one. (stuck at penalty shootout part,duh.). Please pray for my group k. Adios!


regards,

28 January 2015

when..

ASSALAMMUALAIKUM W.B.T. peeps !

pabila lebih utamakan kerja yg due 2 MAC berbanding ESOK kerana minat..
watever. janji dah siap assignment. alhamdulillah. :3




korang dah siap assignment csc? 

***update---assignmentku direject, kena tunggu dah blajo chapter function dlu ghupanya...huhu


regards,

27 January 2015

c programming source code sharing #5 : Buying Ticket/Booking Hotel using switch

ASSALAMMUALAIKUM W.B.T. peeps !

question example:

Ticket Type             Code         Price
Bed Class                   D             65
Standard Class           E              40
Economy Class           S              29

Ask user to input ticket type's code & number of seats they want to buy.
Display total price including 6% government tax.

snapshot of source code :
CLICK THE IMAGE FOR LARGER VIEW

CLICK HERE FOR THE C FILE (can copy&paste and try to compile on your own compiler&edit)

regards,

c programming source code sharing #4 : Buying Ticket/Booking Hotel using if...else

ASSALAMMUALAIKUM W.B.T. peeps !

question example:

Room Type        Code         Price
Deluxe                  D             220
Exclusive              E             170
Single                   S              130

Ask user to input room's code & number of days they are staying.
Display total price including 6% government tax.

snapshot of source code :
CLICK THE IMAGE FOR LARGER VIEW

CLICK HERE FOR THE C FILE (can copy&paste and try to compile on your own compiler&edit)

regards,