Computer Programming – I (24CP101T) Lecture Notes PDF
Document Details
Pandit Deendayal Energy University
Dr. Rajeev Kumar Gupta
Tags
Summary
These lecture notes cover various aspects of computer programming, including the basics of C programming, data types, arrays, functions, file handling, computer systems, and computer architecture.
Full Transcript
Computer Programming – I (24CP101T) Dr. Rajeev Kumar Gupta Assistant Professor Pandit Deendayal Energy University Gandhinagar, Gujarat 1 Unit 1: Ba...
Computer Programming – I (24CP101T) Dr. Rajeev Kumar Gupta Assistant Professor Pandit Deendayal Energy University Gandhinagar, Gujarat 1 Unit 1: Basics of Programming Introduction to Computer Programming, Features of C language, Structure of C program, program execution flow, C Tokens, variables, Data types, Operators, Decision control statements-if, switch, go to statement. Loop control structures- while, do-while, for loop, Break statement, Continue statement Unit 2: Derived Data types Array: one dimensional and multidimensional array, Declaration, initialization, Array Manipulations. Matrix operations, String-Basic Concepts, Inbuilt String manipulation Functions, Pointer, Pointer arithmetic, Pointer to pointer, Array of Pointers Unit 3: Function and Structure Introduction to user defined functions, Types of Functions, Call by value-call by reference, recursion, pointers to functions, Structures, Array of Structure, Union Unit 4: File Handling File handling in C, Different types of files, Operations on Files such as File creation, File deletion, File access modes such as read, write, append, File concatenation, File handling using seek function. Computer System Input devices: allow users to enter input to the computer (mouse, keyboard, microphone, camera) Output devices allow the computer to display output to the user (monitor, printer, speaker) Input/output devices: used by the computer to store data and/or communicate with other computers (CD-ROM, floppy drive, hard drive, modem, network) 4 Computer System Architecture Source: https://www.learncomputerscienceonline.com/what-is-computer-program/ 5 Computer Languages To communicate with the computers, we need some languages. The computer language is defined as code or syntax which is used to write programs or any specific applications. Computer language can be classified into three categories Machine Language Assembly Language High-level Language 6 Machine Level Language The machine language is sometimes referred to as machine code or object code which is set of binary digits 0 and 1. The machine can only understand machine language. It is considered a native language as it can be directly understood by a central processing unit (CPU). Example of machine language for the text “Hello World”. 01001000 0110101 01101100 01101100 01101111 00100000 01010111 01101111 01110010 01101100 01100100. The machine language is not so easy to understand, as the language uses the binary system in which the commands are written in 1 and 0 form which is not easy to interpret. 7 Assembly Level Language This is the second generation programming language. It is a development on the machine language, where instead of using only numbers, we uses mnemonics or symbolic instructions. The assembly language is considered a low-level language for microprocessors and many other programmable devices. In assembly language, the programmer does the operation which can be directly executed on a central processing unit (CPU). Ex. The language has certain drawbacks as it does not contain any variables or functions in programs and also the program is not portable on different processors. The other drawback of assembly language is the code cannot be reused and the language is not so easy to understand. 8 Source: http://computerscience.chemeketa.edu/cs160Read er/ProgrammingLanguages/Assembly.html Source: https://www.chegg.com/homework-help/questions-and-answers/10-using- tables-15-4-15-5-convert-following-machine-code-assembly-language-starting- addres-q29939739 9 High-level Language High-level languages are like English language, with less words also known as keywords and fewer ambiguities. The development of higher-level language is done for a programmer to write a human-readable program that can be easily understood by any user. The syntax used and the programming style can be easily understood by humans if it is compared to low-level language. Examples of some high-level languages are given below Visual Basic, C, C++, Java, Python etc. As the program written in a high-level language is not directly understood by the computer system. Before the execution of high-level programs, it needs to be converted to machine level language. 10 Computer Programming Languages- Types & Levels Source: https://tr.pinterest.com/pin/454019206185132399/ 11 Compiler The compiler is software that converts a program written in a high- level language (Source Language) to a low-level language (Object/Target/Machine Language/0, 1’s). Without compilation, no program written in a high-level language can be executed. For every programming language, we have a different compiler 12 Assembler An assembler is responsible for translating low-level assembly code into machine code. Assembly language code includes mnemonics or symbols/instructions such as ADD, MUX, DIV, SUB, MOV, and so on. These mnemonics are converted to binary code by an assembler. 13 Interpreter Interpreter is a program that converts the high level language into the bit format i.e. machine language. The function of the interpreter and compiler is the same but the interpreter translates one line at a time and executes it. No object code is produced so every time when the program has to be run it is to be interpreted first. Interpreters, however, have usefulness in areas where speed doesn’t matter (e.g., debugging and training) and it is possible to take the entire interpreter and use it on another Instruction Set Architecture. 27 July 2024 14 15 Computer Program Compilation Process 16 Information Security Office of Budget and Finance Education – Partnership – Solutions Questions and Discussion 51