CSC202A Assignment 1 (Complete)
CSC202A Assignment 1 (Complete)
Task 1
Unix is an Operating System that is genuinely the foundation of all Operating Systems such as
POSIX. It was created in the late 1960s by Ken Thompson, Dennis Ritchie, and others in the
AT&T Laboratories.
Unix deals with how the computer works by driving the processor, memory, circle drives,
consoles, video screens, and by performing helpful tasks for the users. Unix Operating System is
intended for multiple users. That is multiple users may have numerous undertakings running
concurrently. It also has a graphical user interface (GUI) like Microsoft Windows which
provides an easily operated environment.
Unix programs are planned around some core philosophies of reasoning that incorporate
necessities such as single-purpose, interoperable, and working with a normalized text interface.
Unix systems are worked around a core kernel that administers the system and other processes.
Unix Operating System is a multi-user and time-sharing system. It can handle different users
simultaneously. Based on time-sharing, the Unix Operating System can carry out commands
given by different users.
2. Multitasking
The multitasking feature of Unix allows more than one program can be run at the same time. The
fundamental of performing various tasks is maximizing the use of CPU resources. This also
allows users to carry out different tasks at a time.
3. Modularity
Modularity is a significant feature of the Unix Operating System. Unix is comprised of plenty of
modules. Therefore, users can add as well as delete models according to their necessities.
Unix Operating System uses a hierarchical file structure. This structure first consists of the root
directory and can contain multiple documents or files. Furthermore, hierarchical file structure
allows simple maintenance and skilled execution and has the greatest flexibility in gathering data
in a way that mirrors its regular state. There is no limitation on the number and size of files in
Unix.
5. Powerful Security
Unix Operating System has a powerful security element. People can utilize the system just when
they have the right of access to the users or files. Unix Operating System serves security to
different levels. The profiles of different users and their passwords are protected by external
security. File and directory permissions need to be set under internal security.
6. Portability
Unix Operating System has over 200 utility programs for different functions. Thus, by joining
existing utilities, new utilities can be constructed easily. Because of that, it can easily complete
tasks such as text processing, sorting, and searching (Chaurasiya, 2020).
Task 2
1. Structured Language
Modularity is the concept of storing C programming language code as libraries for additional
future uses. The majority of the C programming language’s powers are mastered by its library,
while the C programming language itself does very little only. Furthermore, the C language has
its library to resolve regular issues such as we can utilize specific functions through header files
stored in the library. Furthermore, modularity also is the concept of designing applications in
subroutines in a process-oriented approach which means that code can be broken in the
subprogram.
For instance,
#include <stdio.h>
void sum()
void sub()
…
}
First of all, the C programming language is simple. This is because the C language can be written
in simple English language so that it is easy for general programmers to understand and develop.
Also, in secondary schools or universities, the C language is usually taught as an introductory
programming language. Over the long haul, it is undeniably true that it is easier to learn any
other programming language if you are familiar with the C language.
3. Case Sensitive
C programming language is case sensitive which means that the C language handles lowercase
and uppercase letters separately. For example, if we declare an integer variable ‘g’ and we enter
‘G’ instead of ‘g’, it will mean a completely different meaning.
4. Portability
C programming language has great portability. This is because, without any changes or slight
changes, programs are written in C language can be run and compile on any system. To
illustrate, the. C file in C language contains source code and can be edited. However, the .exe file
contains the application and can be executed only. When any C program is written and compiled
on a Windows operating system, the program can easily run on other window-based systems.
When the .exe file is copied to any computer that contains the Windows operating system, it will
work appropriately, in light of the fact that the native code of the application is the same as the
operating system. However, this .exe file cannot be executed on other operating systems.
5. Compiler-Based
Task 3
The C programming data type is a name or a label, which is used to define the data type for
storage or operation. Here is all the primary data types syntax:
1. int
Integers are whole numbers that can have both zeroes, positive and negative qualities however
no decimal qualities. The size of ‘int’ is generally 4 bytes (32 bits). Int is used to declare an
integer variable. Declaring multiple variables at once is allowed.
2. float
3. double
The keyword ‘double’ is similar to ‘float’ as both of them are used to hold real numbers.
However, the difference is the size of ‘double’ is 8 bytes whereas the size of ‘float’ is 4 bytes.
4. char
Character type variables can be declared by using the keyword ‘char’ and the size of ‘char’ is 1
byte.
5. void
‘void’ is a null data type. It has no value. ‘void’ is used in the functions that won’t return any
value to the calling function.
‘short’ and ‘long’ are type specifiers. The size of ‘short’ is 2 bytes and the size of ‘long’ is 4
bytes.
The variables a and b can store integers whereas the variable c can store floating-point numbers.
‘signed’ and ‘unsigned’ are type modifiers in the C programming language. They are used to
change the data storage of the data.
The variable definition determines a data type and contains a rundown of at least one variable of
that type.
‘type’ should be a substantial C data type. Valid C data type includes ‘char’, ‘int’, ‘float’,
‘double’, and any user-defined objects. However, the ‘variable_list’ should comprise at least one
identifier name and be separated by commas.
For example, the line ‘double e, f, g’ orders the compiler to create variables of type ‘double’
named e, f, and g.
In addition, we can assign initial values for the variables in their declaration.
The variable declaration provides the compiler with a guarantee that the variable has a given
name and type for the compiler to continue with further compilation and not necessarily to
request the complete details regarding the variable. Variable definitions are important only at
compile time. When connecting the program, the compiler needs the actual variable definition.
Variable declarations are very helpful especially while using multiple files and defining variables
in one of the files which will be accessible when connecting the program. The keyword ‘extern’
is used to declare variables everywhere. In a C program, although a variable can be declared
many times, it can only be defined just a single time in a file, function, or block of code.
Task 4
The token in the C programming language is the main idea utilized in fostering a C program.
Assume that even we have plenty of words, without joining them, we can’t make a complete
sentence. Similarly, we must use tokens in the C language to develop applications. Thus, we can
say that the token in the C language is the cornerstone of the C programming language. C
language supports 6 types of tokens which are keywords, identifiers, strings, operators,
constants, and special symbols (ashutoshjoshi, 2021).
Code:
Keywords
Output:
Code:
Switch
Output:
Code:
Conditional Operators
Output:
In C language, the C preprocessor is a macro processor. The C compiler will automatically use it
to convert the program before the actual compilation (execute the preprocessor instructions
before compilation). C preprocessor allows the program to define macros, so it is called a macro
processor. A macro is a piece of code replaced by the value of a macro. It is defined by the
#define directive.
#define example
Code:
Output:
#undef example
Code:
Output:
Compilation time error. This is because ‘PI’ was not declared in this scope.
Code:
Output:
Task 5
int i = 25;
float f = 0.5;
double d = 1.5;
x1 = 0.5 + 250 – 50
x1 = 250.5 – 50
*/
float x2=i / f + si * d;
/*
x2 = 50 + 15
*/
float x3=(double) i / si * f;
/*
x3 = 25.00 / 10 * 0.5
x3 = 2.5 * 0.5
*/
/*
x4 = 50 / 25 + 1 (because of the (int)) / 0.5 (do division first)
x4 = 2 + 2
*/
References
ashutoshjoshi. (2021, February 10). C/C++ Tokens. Retrieved from GeeksforGeeks:
https://www.geeksforgeeks.org/cc-tokens/
Chaurasiya, A. (2020, November 05). Read Some Features of Unix Operating System. Retrieved from
learn4seo: https://learn4seo.com/features-of-unix-operating-system/
Help, S. T. (2021, May 30). What Is Unix: A Brief Introduction To Unix. Retrieved from Software Testing
Help: https://www.softwaretestinghelp.com/unix-introduction/