0% found this document useful (0 votes)
29 views

Spring 2024 - CS508 - 1

The document provides instructions for an assignment on programming languages in the CS508 course. It details submission requirements, objectives of the assignment, and contains 3 questions comparing C and Ada programming languages.

Uploaded by

Nasir waqas
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)
29 views

Spring 2024 - CS508 - 1

The document provides instructions for an assignment on programming languages in the CS508 course. It details submission requirements, objectives of the assignment, and contains 3 questions comparing C and Ada programming languages.

Uploaded by

Nasir waqas
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

CS508 – Modern Programming Languages

Total Marks: 15
Assignment No. 01
Semester: Spring 2024 Due Date: 29-April-2024

Instructions:

Please read the following instructions carefully before submitting assignment:

You need to use MS word document to prepare and submit the assignment on VU-LMS.

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

 The assignment is submitted after due date.


 The assignment is not in the required format (doc or docx)
 The submitted assignment does not open or file is corrupt.
 Assignment is copied (partial or full) from any source (websites, forums, students,
etc)

Objectives:

The objective of this assignment is to enhance the learning capabilities of the students about:

 Introduction to Programming Language


 Keywords
 If Statement

If you have any confusion, you can send your query at [email protected]

1
CS508 – Modern Programming Languages
Total Marks: 15
Assignment No. 01
Semester: Spring 2024 Due Date: 29-April-2024

Question No. 1: Marks: 5


Compare the following code snippets in C and Ada. How do the operators and data types differ between the two
languages?

C Code Snippet:

Ada Code Snippet:

2
CS508 – Modern Programming Languages
Total Marks: 15
Assignment No. 01
Semester: Spring 2024 Due Date: 29-April-2024

Solution;

Operators:
 Both C and Ada use similar arithmetic operators for addition (+), Subtraction (-),
Multiplication (*), and division (/),
 Both languages use the same assignment opterator (-) to assign values to variables.

Data Types:
 In C, the variables a, b, sum, difference, product, and quotient are declared using the int data
type, which represents integers.
 In Ada, the variable A, B, sum Deference, Product, and Quotient are also declared as integers
using the integer data type.
 Both C and Ada use similar syntax for variable declaration, using the variable name followed
by the data type.

Output:
 In C, the output is printed using printf() function calls with the appropriate format specifiers for
integers (%d).
 In Ada, the output is printed using Ada.Text_IO.Put_Line() function calls. However, there`s a typo
(Ada.Text_IC should be Ada.Text_IO). The conversion of integers to strings is done using the ‘image
attribute of the Integer type.

Question No. 2: Marks 5

You are required to fill out the following table correctly by writing the name of appropriate language in front
of each row.

3
CS508 – Modern Programming Languages
Total Marks: 15
Assignment No. 01
Semester: Spring 2024 Due Date: 29-April-2024

Statement Appropriate
Language

The programming language was designed primarily for hardware description. APL

The programming language known for its powerful operators for string pattern SNOBOL
matching but suffered from poor readability and maintainability.

The first programming language introduced the concept of a class, which served as SIMULA 67
the basis for data abstraction.

The programming language was primarily designed for teaching structured Pascal
programming and gained popularity for its simplicity and size.

The programming language designed for systems programming at Bell Labs, whichC-1972
evolved from B and was influenced by ALGOL 68.

Question No. 3: Marks: 5

Suppose you as a programming student going to learn how to use the “if statement” in 2 different
programming languages like C and Ada.

Let’s first consider the following C “if statement”.

if (some condition)
//

Now consider the “if statement” in Ada programming language.

if (some condition) then

4
CS508 – Modern Programming Languages
Total Marks: 15
Assignment No. 01
Semester: Spring 2024 Due Date: 29-April-2024

-- do this
end if
-- now do this

Now by keeping an eye on the above codes, answer the following question:

How does the "if statement" differ between C and Ada? Justify your answer with valid
reason.

Answer:

Syntax:

 In C, the syntax of the “if statement “ is simpler and follows the from: If (condition). The
condition is encolosed in parentheses, and there is no explicit keyword to denote the end
of the condition.
 In Ada, the syntax of the “If statement” is more structured. It in parentheses, and the
keyword then is used to indicate the start of the block of code to be executed if the
condition is true. Additionally, the keyword end if is used to denote the end of the “if
statement” block.

Block Sturcture:

 In C, the block of code to be executed if the condition is true is enclosed within curly
braces {…}. There is no explicit keyword to denote the end of the block, but the closing
curly brace indicates the end of the block.
 In Ada, the block of code to be executed if the condition is true is encolosed within the
then and end if keywords. This provides a more explicit and structured way of defining
scope of the “if statement”.

Readability and Maintainability:

 Ada’s structured syntax with explicit keywords such as then and end if enhances
readability and maintainability by clearly delineating the start and end of the “if
statement” block. This can make it easier for prorammers to understand and debug code.
 In C, while the syntax is simpler, the lack of explicit keywords to denote the beginning
and end of the “if statement” block may lead to slightly reduced readability and could
potentially make the code more error-prone, especially in complex codebases.

You might also like