Spring 2024 - CS508 - 1
Spring 2024 - CS508 - 1
Total Marks: 15
Assignment No. 01
Semester: Spring 2024 Due Date: 29-April-2024
Instructions:
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:
Objectives:
The objective of this assignment is to enhance the learning capabilities of the students about:
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
C 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.
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.
Suppose you as a programming student going to learn how to use the “if statement” in 2 different
programming languages like C and Ada.
if (some condition)
//
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”.
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.