Skip to main content

Posts

Showing posts from April, 2021

Quiz based on Digital Principles and Computer Organization

1) Base of hexadecimal number system? Answer : 16 2) Universal gate in digital logic? Answer : NAND 3) Memory type that is non-volatile? Answer : ROM 4) Basic building block of digital circuits? Answer : Gate 5) Device used for data storage in sequential circuits? Answer : Flip-flop 6) Architecture with shared memory for instructions and data? Answer : von Neumann 7) The smallest unit of data in computing? Answer : Bit 8) Unit that performs arithmetic operations in a CPU? Answer : ALU 9) Memory faster than main memory but smaller in size? Answer : Cache 10) System cycle that includes fetch, decode, and execute? Answer : Instruction 11) Type of circuit where output depends on present input only? Answer : Combinational 12) The binary equivalent of decimal 10? Answer : 1010 13) Memory used for high-speed temporary storage in a CPU? Answer : Register 14) Method of representing negative numbers in binary? Answer : Two's complement 15) Gate that inverts its input signal? Answer : NOT 16)...

Control statements

CONTROL STATEMENTS Till now we know that the code in the C program is executed sequentially from the first line of the program to its last line. That is, the second statement is executed after the first, the third statement is executed after the second, so on and so forth. Although this is true, in some cases we want only selected statements to be executed. Control flow statements enable programmers to conditionally execute a particular block of code. There are three types of control statements: decision control (branching), iterative (looping), and jump statements. While branching means deciding what actions have to be taken, looping, on the other hand, decides how many times the action has to be taken. Jump statements transfer control from one point to another point. Decision Control Statements C supports decision control statements that can alter the flow of a sequence of instructions. These statements help to jump from one part of the program to another depending on whether a parti...

Type conversion and typecasting

TYPE CONVERSION AND TYPECASTING Type conversion or typecasting of variables refers to converting a variable of one data type into another. While type conversion is done implicitly, casting has to be finish explicitly by the programmer.  We will discuss both these concepts here. Type Conversion Type conversion is finish when the expression has variables of different data types. So to calculate the expression, the data type is upgrade from lower to higher level where the hierarchy of data types can be given as: double, float, long, int, short, and char. For example, type conversion  is automatically done when we assign an integer value to a floating point variable. Consider the following code: float x; int y = 3; x = y; Now, x = 3.0, as integer value is automatically converted into its same floating point representation. Typecasting Typecasting is also known as forced conversion. It is complete when the value of one data type has to be converted into the value of another data ty...

Operators and Expressions

C program important points Operators And Expressions C language supports many types of operators, which can be used with  variables and constants to form expressions. These operators can be divided into the following major groups: *Arithmetic operators * Relational operators * Equality operators  * Logical operators * Unary operators  * Conditional operator  * Bitwise operators * Assignment operators * Comma operator  * Sizeof operator We will now discuss all these operators. Arithmetic Operators Consider three variables declared as, int a=9, b=3, result; We will use these variables to explain arithmetic operators.  Below Table shows the arithmetic operators, their syntax, and usage in C language. Table : Arithmetic operators In Table a and b (on which the operator is applied) are called operands. Arithmetic operators can be applied to any integer or floating point number. The addition, subtraction, multiplication, and division (+, –, *, and /) ...

Input and Output Functions

INPUT AND OUTPUT FUNCTIONS The most fundamental operation in a C program is to accept input values from a standard input device and output the data produced by the program to a standard output device. we can assign values to variables using the assignment operator ‘=’. For example, int a = 3; What if we want to assign value to variable a that is inputted from the user at run-time? This is done by using the scanf function that reads data from the keyboard. Similarly, for outputting results ofthe program, printf function is used that sends results to a terminal. Like printf and scanf, there are different functions in C that can carry out the input–output operations. These functions are collectively known as Standard Input/ Output Library. A program that uses standard input/output functions must contain the following statement at the beginning of the program: #include <stdio.h> scanf() The scanf()function is used to read formatted data from the keyboard. The syntax of the scanf() fu...

Writing the first C Program

WRITING THE FIRST C PROGRAM To write a C program, we first required to write the code. For that, open a text editor. If you are a Windows user, you may use Notepad and if you prefer working on UNIX/Linux, you can use emac or vi. Once the text editor is opened on your screen, type the following statements: #include <stdio.h> int main() { printf("\n Welcome to the world of C ");// prints the message on the screen return 0;// returns a value 0 to the            operating system } After writing the code, select the directory of your choice and save the file as first.c. #include <stdio.h> This is the first statement in our code that includes a file called stdio.h.  This file has some in-built functions. By simply including this file in our code, we can use these functions directly. stdio basically stands for Standard / Input /Output, which means it has functions  for input and output of data like reading values from the keyboard and printin...

Variables and Constants

VARIABLES AND CONSTANTS A variable is defined as a meaningful name given to a data storage location in the memory of computer. A variable, is used to refer to the address of the memory where the data is stored. C language has two basic kinds of variables. Numeric Variables Numeric variables are used to store the values of integer values or floating point values. Modifiers like short, long, signed, and unsigned can also be used along with numeric variables. The difference between signed and unsigned numeric variables is that signed variables can be negative or positive but unsigned variables can only be positive. Therefore, by using an unsigned variable we can develop the maximum positive range. When we neglect the signed/unsigned modifier, C language automatically makes it a signed variable. To assign an unsigned variable, the unsigned modifier must be explicitly added during the assignation of the variable. Character Variables Single characters enclosed within single quotes are called...

Basic data types

BASIC DATA TYPES Data type defines the group of values that a data item can take and the operations that can be performed on the item. C language provides four basic data types. Below table lists the data types,  their size, range, and usage for a C programmer. The char data type is of one byte and is used to store single characters. Note that C does not give any data type for storing text. This is because text is made up of individual characters.You might have been surprised to see that the range of char is given as –128 to 127. char is used to store characters not numbers, so why this range? The answer is that in the memory, characters are stored in the form of ASCII codes. For example, the character ‘A’ has the ASCII code of value 65. In memory we will not store ‘A’ but stored as 65 (in binary number format).  Table: Basic data types in c In addition, C also supports four modifiers two sign specifiers (signed andunsigned) and two size specifiers (short and long)...

Identifiers and Keywords

IDENTIFIERS AND KEYWORDS Every word in a C program is either a keyword or an identifier. Identifiers Identifiers are normally names given to program elements such as variables,  arrays, and functions. They are grouped by using a sequence of letters (both uppercase and lowercase), numerals, and underscores. Following are the rules for creating identifier names: * Identifiers cannot adds any special characters or punctuation marks  (like #, $, ^, ?, ., etc.) except the underscore “_”. * There cannot be two successive underscores. * Keywords cannot be used as identifiers. * The case of alphabetic characters that make the identifier name is significant. For example, ‘FIRST’ is different from ‘First’ and ‘first’. * Identifiers must start with an underscope or a letter. However, use of underscore as the first character must be ignored because several complier-defined identifiers in the standard C library have underscore as their first character. So, inadvertently copied names may ca...

Introduction to C Programs

INTRODUCTION The programming language ‘C’ was developed by Dennis Ritchie in the early 1970s at Bell Laboratories. Although C was first developed for writing system software, today it has become such a famous language that a various of software programs are written using this language. The main advantage of using C for programming is that it can be easily used on different types of computers. Many other programming languages such as C++ and Java are also based on C which means that you will be able to learn them easily in the future. Today, C is mostly used with the UNIX operating system. Structure of a C program A C program contains one or more functions, where a function is defined as a group of statements that perform a well-defined task.The program defines the structure of a C program. The statements in a function are written in a logical series to perform a particular task. The most important function is the main() function and is a part of every C program. Rather, the execution o...

Computer Security Classification

Computer-Security Classifications  * No computer system can be 100% safe, and attempts to make it so can fastly make it not usable. * However one can establish a level of faith to which one feels "safe" using a given computer system for specific security needs. * The U.S. Department of Defense’s "Trusted Computer System Evaluation Criteria" defines four broad levels of faith, and sub-levels in some cases: • Level D is the minimum trustworthy, and incorporate all systems that do not meet any of the more strict criteria. DOS and Windows 3.1 fall into level D, whichhas no user identification or authorization, and anyone who sits down has full process and control over the machine. • Level C1 adds user identification and authorization, and some means of  controlling what users are permited to process what files. It is constructed for use by a group of mostly cooperating users, and describes most common UNIX systems. • Level C2 adds individual-level control and monitoring...