ADS

CS508 Assignment 1 Solution Spring 2021 - CS508 Assignment 1 Solution File

 CS508 Assignment 1 Solution Spring 2021

CS508 Assignment 1 Solution File 

CS508 Assignment 1 Solution Spring 2021 - CS508 Assignment 1 Solution File

Cs508 Assignment 1 Solution 2021

 

Question # 1:                                                                                  Marks: 15

 

The following code snippet, used in a typical program to print "G" on screen using star pattern,

contains two loops and some nested if else statements. Which are difficult to understand as they

do not contain any starting and ending keywords against each statement. You, being a programing

language expert, are given a task to increase the readability by putting proper starting and

ending keywords (see valid keywords given below) at appropriate places to get the desired result.

 

function printG()

START_FUNCTION

variable height = 5

variable width = (2 * height) - 2

variable i = 0

variable j = 0

loop (i < height)

START_LOOP

j = 0 loop

(j < width)

START_LOOP

if ((i == 0 II == height 1)&& (j == 0 j == width - 1))

START_IF

print(" ")

END_IF

else if (j == 0)

START_ELSE_IF

printt("*'")

END_ELSE)IF

else if (i == 0 && j <= height)

START_ELSE_I

Print("*")

END_ELSE_IF

else if (i == height / 2 && j > height / 2)

START_ELSE_IF

print("*")

END_ELSE_IF

else if (i > height / 2&& j = width - 1)

START_ELSE_IF

print("*")

END_ELSE_IF

else if (i == height – 1

&& j < width)

START_ELSE_IF

print("*")

END_ELSE_IF

else

START_ELSE

print ("")

END_ELSE

J++

END_LOOP

print(“\n”)

i++

END_LOOP

END_FUNCTION



Question # 2:                                                                                  Marks: 5

 Modern high-level Programming languages fall in different categories, like; Imperative,

Functional, Logic (declarative) and Object-oriented. You, being programming language expert,

are required to mention the categories of following languages:

  

#

Languages

Categories

1

SNOBOL

Imperative

2

LISP

Functional

3

ADA

Imperative and Object-oriented

4

FORTRAN

Imperative

5

C#

Imperative and Object-oriented

 

cs508 assignment 1 solution 2021,

cs508 assignment no 1 solution spring 2021,

cs508,

cs508 solution,

Post a Comment

0 Comments