Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

National University of Computer & Emerging Sciences

CS214: Programming Fundamentals A#3


Sections: A, B, C
Instructor: Azhar Rauf
Issue date: TA: Talha Anis (i150533) Due date:

Sunday Friday
For queries, contact:
Feb 12th 0335 5703007 Feb 24th
i150533@nu.edu.pk

Assignment
Solo Group Quizbased
Type

Submission
Online Inclass Either
Type
Follow guidelines
Submission 1. Filename must be
1. Attach this cover for the submission
Guidelines i<ROLL#> followed
page. type checked.
by the suffix.
2. Only use A4size
(Read under 2. Submit .cpp, .jpeg, Any submission
blank white paper
Submission etc. in the
(70g). attempted < 70%
Type designated SLATE
3. Staple all pages. is not marked for
Column) folder in
4. Due at class start. credit.
Assignments tab.

Name: _____________________________ Roll No: ________________

Signature: _________________________ Section: ________________

ImportantNotes:

1. ZERO Tolerance Policy for plagiarism and


cheating.
2. Violators assignments will be voided, they may ForTAuseonly:
receive F in the course and/or will be reported to the
CheckedbyTA
Department Discipline Committee.
Plagiarism Yes No
3. No retake or allocation of average marks for %Attempted
assignments in any case, irrespective of the reason, TotalMarks
genuine or otherwise.
MarksObtained

NUCES-FAST: Spring17: PF (EE) Assign # 03 Page 1/3


Slight plagiarism can lead you to F. Better not to submit assignment instead of copying.
NumberConverterProgram
WriteaC++programusingfunctionstoconvert:
a. Decimaltobinary
b. Binarytodecimal
c. Decimaltohex
d. Hextodecimal

Completetheprogramskeletongivenbelow:
#include<iostream>
#include<string>
usingnamespacestd;

intmain()
{
intdecimal=0;
stringbinary;
stringhex;
//Youaresupposedtotakethesenumbersfromtheuser

cout<<"Thebinaryvalueof"<<decimal<<"is"<<decimalToBinary(decimal)<<endl;
//previouslywasinsideifstatement
cout<<"Thehexvalueof"<<decimal<<"is"<<decimalToHex(decimal)<<endl;//previously
wasinsideifstatement

if(validBinary(binary))
{
cout<<"Thedecimalvalueof"<<binary<<"is"<<binaryToDecimal(binary)<<endl;

}
else
cout<<"Invaldbinaryvalue"<<endl;

if(validHex(hex))
{
cout<<"Thedecimalvalueof"<<Hex<<"is"<<hexToDecimal(hex)<<endl;

}
else
cout<<"Invaldhexvalue"<<endl;

return0;
}
NOTES:

1. ThefunctionvalidBinary(binary)checksthevalidityofthebinaryinputtakenfromuser
(i.e.itshouldonlyhave0or1).
2. ThefunctionvalidHex(hex)checksthevalidityofthehexinputtakenfromuser(i.e.it
shouldonlyhavenumbersfrom09andalphabetsfromAF).

NUCES-FAST: Spring17: PF (EE) Assign # 03 Page 2/3


End of Assignment No. 3

NUCES-FAST: Spring17: PF (EE) Assign # 03 Page 3/3

You might also like