3
SCA Pvt. Ltd. (Sharma Computer Academy) Author: Saurabh Shukla Chapter-1 Fundamental of Programming What is computer? Computer is an electronic device that takes input, process it and gives output. Examples are desktop computers, Laptop, Palmtop, Super computer, embedded systems, etc. Is computer really works on 0 and 1? There is no physical significance of 0 and 1 in computer system. 0 and 1 are just representation of two states of voltage levels in digital circuits. If there is a supply of high volt in the circuit it is termed as 1 and for low volt it is 0. These encoding help us to handle any sort of information through digital circuits. What is Hardware? Hardware is a comprehensive term for all of the physical parts of a computer, as distinguished from the data it contains or operates on, and the software that provides instructions for the hardware to accomplish tasks. What is file? A computer file is a data bundle created by a program used to refer back to saved work or support the operating of the program. Files are of different types, which mean information is encoded in a particular manner. Each such manner is a separate file format. Notice files stored in your computer’s memory disk, each has some name for identification followed by file extension. File name and extension are separated by a dot operator. File extension tells about type of the file. For example track1.mp3 is a file with extension mp3 which means it is an audio file. Among the several file formats, we are concern about a special file format with extension exe. These files are called executable files. For beginners of C language should understand the purpose of learning programming language. Softwares are programs (or a collection of programs) developed by writing instructions (that need to be executed during execution) in certain programming language. C language is just one of them. When we say we are going to develop software through C language, it means you are attempting to create an exe file. In loose terms, we can say an exe file is your software. So the abstract is, you are here to write code in C language which then converted in to an exe file. You can deliver this exe file to your client. He can enjoy your software without seeing your code. In the later segment you would understand why he can’t see your programming code.

Chapter-1

Embed Size (px)

DESCRIPTION

c1

Citation preview

Page 1: Chapter-1

SCA Pvt. Ltd. (Sharma Computer Academy) Author: Saurabh Shukla

Chapter-1 Fundamental of Programming What is computer? Computer is an electronic device that takes input, process it and gives output. Examples are desktop computers, Laptop, Palmtop, Super computer, embedded systems, etc. Is computer really works on 0 and 1? There is no physical significance of 0 and 1 in computer system. 0 and 1 are just representation of two states of voltage levels in digital circuits. If there is a supply of high volt in the circuit it is termed as 1 and for low volt it is 0. These encoding help us to handle any sort of information through digital circuits. What is Hardware? Hardware is a comprehensive term for all of the physical parts of a computer, as distinguished from the data it contains or operates on, and the software that provides instructions for the hardware to accomplish tasks. What is file? A computer file is a data bundle created by a program used to refer back to saved work or support the operating of the program. Files are of different types, which mean information is encoded in a particular manner. Each such manner is a separate file format. Notice files stored in your computer’s memory disk, each has some name for identification followed by file extension. File name and extension are separated by a dot operator. File extension tells about type of the file. For example track1.mp3 is a file with extension mp3 which means it is an audio file. Among the several file formats, we are concern about a special file format with extension exe. These files are called executable files. For beginners of C language should understand the purpose of learning programming language. Softwares are programs (or a collection of programs) developed by writing instructions (that need to be executed during execution) in certain programming language. C language is just one of them. When we say we are going to develop software through C language, it means you are attempting to create an exe file. In loose terms, we can say an exe file is your software. So the abstract is, you are here to write code in C language which then converted in to an exe file. You can deliver this exe file to your client. He can enjoy your software without seeing your code. In the later segment you would understand why he can’t see your programming code.

Page 2: Chapter-1

SCA Pvt. Ltd. (Sharma Computer Academy) Author: Saurabh Shukla

What is program and process? Program is a set of instruction to perform a particular task. Active state of a program is called process. What is an operating system? Operating system is essential software which provides an interface between user and machine. It acts as a manager in the system, which manages hardware and software resources. It also does process management, memory management and file management. Examples of Operating systems are windows XP, Windows 2007, Linux, etc. Basic Computer architecture It is important to describe the role of few of the hardware resources during execution of program. Earlier we talked about an executable file. Here we are describing execution process of any one of such exe file. Firstly, your program (sum.exe) file is stored somewhere in hard disk of your system. Now we clicked on it to run this program. This click event from mouse is listened by operating system and loads this file from hard disk to RAM (random access memory) using loader (a dedicated program to load content to RAM). Here it is important to note that each time when some program need to be activate, program must load in to RAM. RAM is also known as primary memory which is volatile in nature that is nothing can reside permanently. RAM contains only those programs that are active at particular instant. Operating system allocates memory for our program in RAM. First instruction goes to the processor and resides in instruction register. This instruction is decoded by control unit. Control unit sends appropriate signal to ALU. ALU performs specific task. Registers, control unit and Arithmetic Logic Unit are part of processor. ALU is responsible to perform all kind of arithmetic, logical and shift instructions. Again next instruction moves to processor and stored at instruction register, control unit decode it and sends a signal to ALU. Every instruction of the program executes in similar fashion in a sequential manner. As soon as the last instruction is executed memory of the program will released from RAM. Why Languages? Executable files are machine code which is operating system dependent and hardware dependent. To create such file we need to know about hardware specifications and OS policies. This increases extra learning overhead to the programmer. One easy solution is to learn a simple hardware independent coding language like C. Once you learn C language you can write code (known as source code) and save it as a source file. This code is not readable for machine. You need to convert it into machine code. A software known as compiler is used as a translator, which translates your source code in to object code.

Page 3: Chapter-1

SCA Pvt. Ltd. (Sharma Computer Academy) Author: Saurabh Shukla

Object files containing machine code are not sufficient to understand by computer, you need to link this code with predefined code stored in library files. This can be done with the help of software called linker. Linker generates an executable file. History of C language l C language was developed by Dennis Ritchie in 1972 at AT & T’s Bell Labs, New

Jersy, USA. l C language is inspired from B language which was developed by Ken Thompson. l 80% code of UNIX operating system is written in C language. l C is a middle level language that is a combination of high level and low level

language. l C follows procedure oriented programming approach. l C follows top down approach. IDE for C Integrated Development Environment is a software application that provides comprehensive facilities to computer programmer for software development. An IDE normally consist of: l A source code editor l Compiler or interpreter l Build automation l A debugger There are n numbers of IDEs available for C. They are specific to operating system. These IDEs not only gives you facility to write and edit code but also provide facility to compile and link to create object file and executable file. Technical terminologies Compile: It is a process of compiling your source code and producing object code Debug: It is an activity to remove errors in your source code. Errors are called bugs. Error: Errors are categorized as syntax error(compile time error), Linker error, Run time error, Logical error. These are mistakes in your program which needs to be handled Run: When you run your program it means execution of your program. Syntax: Grammar for computer language Turbo: Software (IDE) developed by Borland Inc.