Assignment 1
Assignment 1
Assignment 1
Submitted to:
Abul Hasnat Md. Saiful Islam
Professor
Department of CSE,NDUB
Submitted by:
Md. Safayet Hossain
ID: 0692320005101034
Department of CSE, NDUB.
Date of Submission: September 6 , 2023
2. [CLO3] [5]:-
Let's go through each constant and determine if it is a valid type in C and identify its data
type if applicable:
1. 'PQR' - This is not a valid constant in C. It consists of multiple characters enclosed in single
quotes, which suggests a character literal. However, character literals in C can only contain
a single character.
2. 15E-2 - This is a valid constant in C. It is a floating-point number written in scientific
notation. The data type for this constant is `double`.
3. 35 - This is a valid constant in C. It is an integer literal, and the data type for this constant is
`int`.
4. 'h' - This is a valid constant in C. It is a character literal, and the data type for this constant
is `char`.
5. -37.491 - This is a valid constant in C. It is a floating-point number, and the data type for
this constant is `double`.
6. .912 - This is a valid constant in C. It is a floating-point number, and the data type for this
constant is `double`.
7. 4,719 - This is not a valid constant in C. Commas are not allowed in numeric literals.
8. 'true' - This is not a valid constant in C. In C, the keyword for a Boolean true value is `true`
(without quotes) when using the `<stdbool.h>` library. Without including the library, `true`
is not recognized as a keyword.
9. "T" - This is a valid constant in C. It is a string literal containing a single character, and the
data type for this constant is `char`.
10. 4.5e3 - This is a valid constant in C. It is a floating-point number written in scientific
notation, and the data type for this constant is `double`.
11. '$' - This is a valid constant in C. It is a character literal, and the data type for this constant
is `char`.
3. [CLO3] [2]:-
In C, the most appropriate variable types for the area of a circle in square inches and the
number of cars passing through an intersection in an hour would be:
1. Area of a circle in square inches: `double`
Reason: The area of a circle can have fractional values, and `double` provides higher
precision compared to other floating-point types like `float`. It is suitable for storing real
numbers with decimal points.
2. Number of cars passing through an intersection in an hour: `int`
Reason: The number of cars passing through an intersection is typically a whole number
(non-negative), and it is unlikely to be a fractional value. Thus, `int` (integer) is a suitable
variable type to represent this quantity.
Here's a C program to compute the area of a circle and the number of cars passing through
an intersection in an hour:
Explanation:
1. The program prompts the user to enter two integers.
2. The user enters "5" and "7".
3. The program reads these values into variables `m` and `n`.
4. `m` is then updated with the value of `m + 5`, which becomes 5 + 5 = 10. 5. `n` is updated
with the value of `3 *