0% found this document useful (0 votes)
14 views5 pages

MRK - Spring 2023 - CS508 - 1 - BC200418274

The document is an assignment for CS508 - Modern Programming Languages, due on May 18, 2023, worth 20 marks. It requires students to format a provided code snippet by adding 'then' and 'end if/else/else if' statements for clarity without using any compiler or interpreter. Strict submission guidelines are outlined, including formatting requirements and consequences for late or improperly formatted submissions.

Uploaded by

arehman.98.786
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views5 pages

MRK - Spring 2023 - CS508 - 1 - BC200418274

The document is an assignment for CS508 - Modern Programming Languages, due on May 18, 2023, worth 20 marks. It requires students to format a provided code snippet by adding 'then' and 'end if/else/else if' statements for clarity without using any compiler or interpreter. Strict submission guidelines are outlined, including formatting requirements and consequences for late or improperly formatted submissions.

Uploaded by

arehman.98.786
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Assignment No.

01
Total Marks: 20
Semester: Spring 2023
CS508 – Modern Programming Languages Due Date: 18th May
2023
BC200418274 – Waqas Hussain
Please read the following instructions carefully before solving & submitting assignment:

Uploading Instructions:
 You are not allowed to use any compiler or interpreter for this assignment.
 You can use Notepad or any other text editor (like Sublime Text, Atom, VS Code etc.) to complete this
code.
 After completion, copy all the code; it must be a simple text, which should not contain any format or
style and paste in a word file or with format of .doc, .docx.
 Upload it on VULMS at assignment section and click on submit button within due date.
 After upload, make sure the submitted code is properly visible and in readable form.
 No assignment will be accepted through email.

Rules for Marking:


It should be clear that your assignment will not get any credit if:

o The assignment is submitted after due date.


o The assignment is not submitted in proper format (i.e. simple text, without any format/style).
o The assignment is fully or partially copied from other student or ditto copy from handouts or Internet;
strict disciplinary action will be taken in this case.
o The submitted code is not readable; during evaluation, submitted code will be checked by using simple text
editor. If code is not readable due to wrong format or style then ZERO marks will be awarded and no
excuse will be accepted in this regard.

Note: Do not put any query on MDB regarding this assignment, if you have any query then email at
[email protected]

Lectures Covered: This assignment covers Lecture # 1 - 8

GOOD LUCK

1
Assignment No. 01
Total Marks: 20
Semester: Spring 2023
CS508 – Modern Programming Languages Due Date: 18th May
2023
BC200418274 – Waqas Hussain

Problem Statement:
The following code snippet contains some conditional (nested if else /else if based) statements. Which are
difficult to understand as they do not contain any starting or ending keywords against each statement. You,
being a programming language expert, are required to put "then" and "end if/else/else if" at appropriate
places to get the desired result.

Code Snippet:
At start, x contains 100 (i.e. x = 100)

if (x > 50)
x = x * 5;
}if (x > 200){
x = x - 200;
}if (x > 350){
x = x - 150;
}else{
x = x + 150;
}
if (x > 400){
x = x - 150;
}if (x < 500){
x = x + 150;
}if (x == 500){
x = x + 200;
}else if (x > 400){
x = x - 100;
}else if (x < 650){
x = x + 100;
}else{
x = x * 5;
}

At end, x contains 350.

2
Assignment No. 01
Total Marks: 20
Semester: Spring 2023
CS508 – Modern Programming Languages Due Date: 18th May
2023
BC200418274 – Waqas Hussain
SOLUTION:

if (x > 50) { then


x = x * 5;
end if
}

if (x > 200){ then


x = x - 200;
end if
}

if (x > 350){ then


x = x - 150;
end if
} else { then
x = x + 150;
end else
}

if (x > 400){ then


x = x - 150;
end if
}

if (x < 500){ then


x = x + 150;
end if
}

if (x == 500){ then
x = x + 200;
end if
} else if (x > 400){ then
x = x - 100;
end else if
} else if (x < 650){ then
x = x + 100;
end else if
} else { then
x = x * 5;
end else
}

3
Assignment No. 01
Total Marks: 20
Semester: Spring 2023
CS508 – Modern Programming Languages Due Date: 18th May
2023
BC200418274 – Waqas Hussain

Note:
This is a language-free code, which does not require any specific programming language to compile or
execute. You are simply required to guess the flow of execution on the basis of value of x and put "then" and
"end if/else/else if" at appropriate places (see the hint given below). Furthermore, you can also add extra
lines or spaces in your solution as well.

Hint:

Difficult to Understand Easily Understandable

if (a > b){ if (a > b){ then


b = 5 b = 5
}else if(a < b){ end if
a = 5 }else if(a < b){then
}else a = 5
a = b end else if
}else then
a = b
end else

Good Luck

4
Assignment No. 01
Total Marks: 20
Semester: Spring 2023
CS508 – Modern Programming Languages Due Date: 18th May
2023
BC200418274 – Waqas Hussain

You might also like