Introduction to IT System M5 (DES00001) PDF

Summary

This document provides an introduction to IT systems, including computer systems, algorithms, flowcharts, and C programming. It covers basic concepts, objectives, and different types of errors and operators.

Full Transcript

Introduction to IT System M5 (DES00001) Brainware University 1 Course Objectives From this course, the students will able to: Define the basic concepts of computer system and recall the ideas of algorithm and flowchart Discuss the basic concepts and i...

Introduction to IT System M5 (DES00001) Brainware University 1 Course Objectives From this course, the students will able to: Define the basic concepts of computer system and recall the ideas of algorithm and flowchart Discuss the basic concepts and ideas of C programming language Explain the concepts of loops and functions and apply in solving a problem Identify the use of structure and pointer and compare the importance of using file in programming language Brainware University 2 Computer System □ Input devices □ CPU (CU+ALU+MU) □ Output devices Brainware University 3 Computer System □ Example of input device – keyboard, mouse etc □ Example of output device – monitor, printer etc □ Control unit (CU) is the brain of computer □ Arithmetic Logic unit (ALU) is used for performing arithmetic and logical operations □ Memory unit (MU) is the memory used for storing data ◦ Primary memory, secondary memory Brainware University 4 Algorithm □ It is a step by step method of solving a problem □ Example: to add two numbers 1. start 2. take first number 3. take second number 4. add first and second number 5. stop Brainware University 5 Features of an algorithm □ Precision ◦ steps precisely defined □ Uniqueness ◦ no ambiguity □ Finiteness ◦ end to some solution □ Input/Output Brainware University 6 Flowchart A flowchart is a graphical representation of an algorithm. It should follow some rules while creating a flowchart Rule 1: Flowchart opening statement must be ‘start’ keyword. Rule 2: Flowchart ending statement must be ‘end’ keyword. Rule 3: All symbols in the flowchart must be connected with an arrow line. Rule 4: The decision symbol in the flowchart is associated with the arrow line. Brainware University 7 Flowchart □ The pictorial representation of the step by step solution of a given problem □ Pictorial representation of an algorithm start terminal box for direction Take 1st & 2nd number I/O box 1st no+ 2nd no Process box stop Brainware University 8 Flowchart for greatest of two numbers Brainware University 9 Error and Types: Unexpected happening or illegal operation performed by the user which results in abnormal working of the program. 1. Compile-time Error: All the errors that are detected and displayed by the compiler are known as compile-time errors. Whenever the compiler displays an error, program will not be able to run. It is therefore necessary that we must fix all the errors before we can successfully compile and run the program. There are two categories of compile-time errors – Syntax errors: A formal set of rules defined for writing a program in a particular language is not followed then the error generated by the compiler is known as syntax error. In other words, syntax errors occur when syntax rules of any programming language are violated. Some of the common examples of syntax errors are missing semicolon, parenthesis etc. Semantic errors: this type of compile time errors indicate an improper use of program statement. These errors occur when statements are not meaningful. For example, use of an undeclared variable come under semantic errors. Brainware University 10 2. Run-time Error: If an application is syntactically correct the it is compiled and translated into machine language and ready to be executed. Run-time errors occur during the execution of a program. These errors will result in the abnormal termination of program. Some of the common examples of run-time errors are number division by zero. 3. Logical Error: In case the program cannot give any error but still giving an incorrect output, it is due to logical errors. These errors occur due to mistakes of the programmer. For example, when a wrong formula is used to calculate any mathematical expression then it gives a logical error. Brainware University 11 C Programming Language □ Developed by Dennis Ritchie □ In 1972 at AT&T Bell Laboratory □ Keyword- word with predefined meaning ◦ Ex-- int, if, void etc □ Identifier- any name given to a variable, function, array etc □ Variable- a name to store data in memory location Brainware University 12 Classifying Data types Basic (primitive/primary) types include: ◦ Integers ◦ Characters ◦ Floating points (real numbers) ◦ Boolean Secondary/derived types include: ◦ Array ◦ Pointer ◦ Structure ◦ String Brainware University 13 Preprocessor directives in C Preprocessor programs provide preprocessor directives that tell the compiler to preprocess the source code before compiling. All of these preprocessor directives begin with a ‘#’ (hash) symbol. The ‘#’ symbol indicates that whatever statement starts with a ‘#’ will go to the preprocessor program to get executed. Examples of some preprocessor directives are: #include, #define, #ifndef, etc. Brainware University 14 Uses □ 'int' (Integers) is used for storing integers values (-5, 0, 5 etc.) □ 'float' is used to for storing decimal numbers (5.5, -5.7 etc.) □ 'char' (character) is used for storing single letter or special symbols (a,C,$ etc.) Brainware University 15 Storage Capacity □ 'int' = 2 bytes (16 bit compiler) = 4 bytes (32 bit compiler) □ 'float' = 4 bytes □ 'char' = 1 byte Brainware University 16 Format specifier □ Format specifiers are needed to access different data types □ int - %d □ float - %f □ double - %lf □ char - %c □ string - %s □ pointer- %p Brainware University 17 Keywords □ They are the fixed defined words with some meaning □ Example : ◦ int ◦ float ◦ char ◦ main ◦ void Brainware University 18 Tokens: Tokensare identifiers or the smallest single unit in a program that is meaningfulto the compiler. In C we have the following tokens: Keywords: Predefined or reserved words in the C programming language. Every keyword is meant to perform a specific task in a program. C Programming language supports 32 keywords. Identifiers: Identifiers are user-defined names that consist of an arbitrarily long sequence of digits or letters with either a letter or the underscore (_) as a first Character. Identifier names can’t be equal to any reserved keywords in the C programming language. There are a set of rules which a programmer must follow in order to name an identifier in C. Constants: Constants are normal variables that cannot be modified in the program once they are defined. Constants refer to a fixed value. They are also referred to as literals. Strings: Strings in C are an array of characters that end with a null character (‘\0). Null character indicates the end of the string; Special Symbols: Some special symbols in C have some special meaning and thus, they cannot be used for any other purpose in the program. # = {} () , * ; [] are the special symbols in C programming language. Operators: Symbols that trigger an action when they are applied to any variable or any other object. Unary, Binary, and ternary operators are used in the C Programming language. Brainware University 19 Identifier □ Any name assigned to represent something □ Example : ◦ Say roll number 1 represents a student ◦ Similarly any name used to represent in C language like variable, function etc Brainware University 20 Variable □ Used to hold values □ It is a named-storage location that holds a value. □ Example : int var; ◦ Here var is a variable that will hold integer data type values ◦ There can be any name except keywords Brainware University 21 Rules for Identifier Name □ Any name except keywords like int, float, if etc. □ It can contains alphabets, numbers etc. □ Must start with a letter □ Contains special character ◦ Underscore (_) only □ First character of name cannot be a number □ It is case-sensitive Brainware University 22 Operators ❑ An operator is a symbol that represents a specific operation to be performed on one or more operands. □ Operator is used to manipulate data and variables □ Example: a + b, where a & b are operands and + is an operator Brainware University 23 Types of Operators □ Arithmetic Operators □ Relational Operators □ Assignment Operator □ Logical Operators □ Conditional Operators □ Bitwise Operators □ Increment/Decrement Operators Brainware University 24 Arithmetic Operators □ Arithmetic operators used to perform arithmetic operations □ The arithmetic operators in C language: + Addition - Subtraction * Multiplication / Division % Modulus Brainware University 25 Relational Operators ❑ Also known as comparison operators, are symbols used in programming languages to compare two values or expressions. These operators allow you to determine the relationship between the values and make decisions based on their comparisons. The relational operators are: > Greater than < Less than >= greater than Equal to > Right Shift

Use Quizgecko on...
Browser
Browser