+ Link For Assignments, GDBs & Online Quizzes Solution |
+ Link For Past Papers, Solved MCQs, Short Notes & More |
CS508 Assignment 01 Fall 2020 Solution / Discussion
Problem Statement:
Problem Statement:The following code snippet contains some conditional (nested if else based) statements. Which are difficult to understand as they do not contain any starting or ending keywords against each statement. You, being a programing language expert, are required to put "then" and "end if/else" 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 > 500) x = x - 350 if (x > 350) x = x - 150 else x = x + 150 else x = x - 100 if (x > 500) x = x - 150 if (x < 500) x = x + 150 if (x == 500) x = x + 200 else x = x + 100 if (x > 650) x = x - 100 else if (x < 650) x = x + 100 else x = x * 5 else x = x + 50
At end, x contains 3250.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" 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)b = 5elsea = 5 if (a > b) thenb = 5end ifelse thena = 5end else
Tags:
+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)
+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)
+ Click Here to Search (Looking For something at vustudents.ning.com?) + Click Here To Join (Our facebook study Group)if (x > 500)
x = x - 150
if (x < 500)
x = x + 150
if (x == 500)
x = x + 200
else
x = x + 100
if (x > 650)
x = x - 100
else if (x < 650)
x = x + 100
else
x = x * 5
else
x = x + 50
At end, x contains 3250.
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" 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) b = 5 else a = 5 |
if (a > b) then b = 5 end if else then a = 5 end else |
Good Luck
#CS5008 Assg No 1 :
Simple way of solution Assignment no.1 cs 508
CS508 Assignment 1 Fall 2020 Solution
#vu #cs508 #AssignmentHelp #assignment #vustudent
link below
#CS508 Assignment 1 IDEA SOL Fall 2020
if (x > 50)
then
x = x * 5;
if (x > 500)
then
x = x - 350;
if (x > 350)
then
x = x - 150;
end if
else
then
x = x + 150;
end else
end if
else
then
x = x - 100;
if (x > 500)
then
x = x - 150;
end if
if (x < 500)
then
x = x + 150;
if (x == 500)
then
x = x + 200;
end if
else
then
x = x + 100;
if (x > 650)
then
x = x - 100;
end if
else if (x < 650)
then
x = x + 100;
end if
else
then
x = x * 5;
end else
end else
end if
else
then
x = x + 50;
end else
end else
end if
CS508 Assignment#01 Solution click on the below link
if (x > 50)
then
x = x * 5;
if (x > 500)
then
x = x - 350;
if (x > 350)
then
x = x - 150;
end if
else
then
x = x + 150;
end else
end if
else
then
x = x - 100;
if (x > 500)
then
x = x - 150;
end if
if (x < 500)
then
x = x + 150;
if (x == 500)
then
x = x + 200;
end if
else
then
x = x + 100;
if (x > 650)
then
x = x - 100;
end if
else if (x < 650)
then
x = x + 100;
end if
else
then
x = x * 5;
end else
end else
end if
else
then
x = x + 50;
end else
end else
end if
if (x > 50)
then
x = x * 5;
if (x > 500)
then
x = x - 350;
if (x > 350)
then
x = x - 150;
end if
else
then
x = x + 150;
end else
end if
else
then
x = x - 100;
if (x > 500)
then
x = x - 150;
end if
if (x < 500)
then
x = x + 150;
if (x == 500)
then
x = x + 200;
end if
else
then
x = x + 100;
if (x > 650)
then
x = x - 100;
end if
else if (x < 650)
then
x = x + 100;
end if
else
then
x = x * 5;
end else
end else
end if
else
then
x = x + 50;
end else
end else
end if
© 2021 Created by + M.Tariq Malik.
Powered by
Promote Us | Report an Issue | Privacy Policy | Terms of Service
We have been working very hard since 2009 to facilitate in learning Read More. We can't keep up without your support. Donate.
We are user-generated contents site. All product, videos, pictures & others contents on site don't seem to be beneath our Copyrights & belong to their respected owners & freely available on public domains. We believe in Our Policy & do according to them. If Any content is offensive in your Copyrights then please email at m.tariqmalik@gmail.com Page with copyright detail & We will happy to remove it immediately.
Management: Admins ::: Moderators
Awards Badges List | Moderators Group
All Members | Featured Members | Top Reputation Members | Angels Members | Intellectual Members | Criteria for Selection
Become a Team Member | Safety Guidelines for New | Site FAQ & Rules | Safety Matters | Online Safety | Rules For Blog Post