C Programming - Lecture notes 1 PDF

Title C Programming - Lecture notes 1
Course Electronic and Communication Engineering
Institution Osmania University
Pages 104
File Size 5.1 MB
File Type PDF
Total Downloads 160
Total Views 352

Summary

G Subba Reddy. M(Comp) SYLLABUS Programming in C BS-106 Unit – I Computer Fundamentals: Introduction of Computers, Classification of Computers, Anatomy of a Computer, Memory Hierarchy, Introduction to OS, Operational Overview of a CPU. Program fundamentals: Generation and Classification of Programmi...


Description

G.Venkata Subba Reddy. M.Sc(Comp.Science)

SYLLABUS Program Programming ming in C

BS BS--106

Unit – I Computer Fundamentals: Introduction of Computers, Classification of Computers, Anatomy of a Computer, Memory Hierarchy, Introduction to OS, Operational Overview of a CPU. Program fundamentals: Generation and Classification of Programming Languages, Compiling, Interpreting, Loading, Linking of a Program, Developing Program, Software Development. Algorithms: Definitions, Different Ways of Stating Algorithms (Step-form, Pseudo-code, Flowchart), Strategy for Designing Algorithms, Structured Programming Concept. Basics of C: Overview of C, Developing Programs in C, Parts of Simple C Program, Structure of a C Program, Comments, Program Statements, C Tokens, Keywords, Identifiers, Data Types, Variables, Constants, Operators and Expressions, Expression Evaluation–precedence and associativity, Type Conversions.

Unit – II Input-Output: Non-formatted and Formatted Input and Output Functions, Escape Sequences, Control Statements: Selection Statements – if, if-else, nested if, nested if-else, comma operator, conditional operator, switch; Iterative Statements–while, for, do-while; Special Control Statement–goto, break, continue, return, exit. Arrays and Strings: One-dimensional Arrays, Character arrays, Functions from ctype.h, string.h, Multidimensional Arrays.

Unit – III Functions: Concept of Function, Using Functions, Call-by-Value Vs Call-by-reference, Passing Arrays to Functions, Score of Variables, Storage Classes, Inline Functions, and Recursion. Pointers in C: Introduction, Address of Operator (&), Arrays and Pointers, Pointers and Strings, Pointers to Pointers, Array of Pointers, Pointer to Array, Dynamic Memory Allocation.

Unit – IV User-defined Data Types: Declaring a Structure (Union) and its members, Initialization Structure (Union), Accessing members of a Structure (Union), Array of Structures (Union), Structures Vs Unions, Enumeration Types. Files in C: Introduction, Using Files in C, Working with Text Files, Working with Binary Files, Files of Records, Random Access to Files of Records, Other File Management Functions.

Silent Features 1. Complete Syllabus Covered According to the latest CBCS Syllabus. 2. Subject deals with Simple and Easy Understanding Language. 3. Includes Internal Assignment. 4. Student & Lecturer Friendly. 5. All the Practical’s are covered according to the Syllabus.

Computer languages are best learned by “Writing & Debugging Programs. Programs.”” Computer Fundamentals and Programming in C is designed to serve for the undergraduate students of computer science, computer applications, and information technology. This book provide a thorough overview of all the fundamental concepts related to computer science and programming. It lays down the foundation for all the advanced courses that a student is expected to learn in the following semesters. This book is devoted to practical C programming. C is currently the premier language for software developers. That’s because it’s widely distributed and standard. Newer languages are available, such as C++, but these are still evolving. C is still the language of choice for robust, portable programming. This book emphasizes the skills you will need to do realworld programming. It teaches you not only the mechanics of the C language. To create a good program you must do more than just type in code. It is an art in which writing and programming skills blend themselves together to form a masterpiece. A wellwritten program not only functions correctly, but is simple and easy to understand. Comments allow the programmer to include descriptive text inside the program. A program should be as simple as possible. A programmer should avoid clever tricks. This book stresses simple, practical rules. This handbook is written for people with no previous programming experience or programmers who already know C and want to improve their style and reliability. You should have access to a computer and know how to use the basic functions.

Author….

M&S PUBLICATIONS

Unit-I Chapter-I Fundamentals of Computers Introduction The computer is one of the most brilliant gifts of science. This device was originally developed by Charles Babbage. Most countries have developed fast due to computerization. Writing a program is essential for a computer. Speed, accuracy, reliability, and integrity are the main characteristics of a computer. Many of the routine activities today at home and in business are done by computers. The computer has proved a friend and servant of science, technology and industry. Most offices, shops, factories and industries use computers. The Internet is a storehouse of information. Telecommunication and satellite imageries are computer based. Computers have made the world a global village today. It is an electronic device for storing and analysing information fed into it, for calculating, or for controlling machinery automatically. Charles Babbage developed this device first in 1812 followed by George Boole in 1854, Howard and Aitten in 1937, Dr. John Nouchly and J. P. Eckert in 1946. These computers were named the first generation equipment. Today, with the 'Artificial Intelligence' technology, we are using fifth generation computers. Each new generation of computers has been smaller, lighter, speedier and more powerful than the earlier ones. Now notebook sized computers like laptop are fairly common. A computer has been dominating technology since 1970s, and has now entered almost all walks of life. Writing a program is essential for running a computer. This job is done by a software engineer. A computer program is a complete list of instructions which the computer accepts in order to solve a problem. There are many different languages that can be used to programme a computer. BASIC, COBOL, FORTRAN, C, C++, JAVA and Visual Basic are some of them. A computer can execute over a million instructions per second without committing and mistake. It can carry our calculations in just a few minutes that would require days if carried out manually. It helps us in solving many difficult problems of multiple calculations. Computer has a huge memory. It can hold large amount of data. In less than 50 years, computers have influenced practically every field of activity. Many of the routine activities today are being performed by computers. Use of computers has reduced the paperwork. Now most of the work is done directly on the computers. The traffic in large cities is controlled by computers. Automation in banks and railway stations has provided relief to the public and staff alike. Ticketing and reservation have become more efficient and convenient. Various types of games like chess and cards can also be played on computers. In medical diagnosis, computers are being used to locate and investigate accurately and precisely abnormalities and diseases. Business transactions and high volume of associated data are easily managed by using computers. The computer gives us many benefits. They can be used as typewriters. When equipped with telephone modems, with the help of computer we can chat across the world. Teleconferencing and video conferencing are also possible. The internet helps us to keep in touch with family and friends. One can get information about every subject known to man, ranging from government law and services. Trade fairs, conferences, market information, education, society and politics.

1

M&S PUBLICATIONS In defence, they help radars, missile and rocket launching. They have opened new avenues of shopping and entertainment. Telecommunication and satellite imagery is computer based. Computerization can play an important role in rural areas in seed research, crop disease management and software development for rural industries. The computer also has its negative side. The rises of cybercrime, the use of chat rooms for indecent discussion, and certain websites, which deal in pornographic material have been noticed. But the advantages and importance outweigh the disadvantages. Through computerization, the world has become a global village today. “A computer is an electronic device which is capable of receiving the inputs (data from the user), storing it for a desired period of time, manipulating it according to the set of instructions (called program) and producing the output to the user in desired form. It performs a variety of operations in accordance to the set of instructions. Advantages of computer The major advantage of using computers is given below. 1. Computers makes it possible to receive, supply and process large volumes of data at very high speed. 2. Computer reduces the cost of all data related operations including, input, output, storage, processing, and transmission. 3. Computer greatly improves the speed of data input, output, processing, and transmission. 4. Computer ensures consistent and error free processing of data. 5. The data input, output, and processing speed of computers has enabled development of many applications requiring speedy continuous monitoring of a process or situation and responding to it very quickly in real time. Disadvantages of Computer The computer can outperform human beings in speed, memory and accuracy but still the computer has limitations. There are following limitations of a computer.  Though computer is programmed to work efficiently, fast and accurately but it is programmed by human beings to do so. Without a program, computer is nothing.  The computer cannot think itself. The concept of artificial intelligence shows that the computer can think.  A Computer cannot care itself like a human. A computer is dependent still to human beings for this purpose.  A computer can retrieve data very fast but this technique is linear. A human being's mind does not follow this rule. A human mind can think randomly which a computer machine cannot.  One of the main limits in the computer is of feeling. A computer cannot feel about some like a human. A computer cannot meet human in respect of relations. Human can feel, think and caring but a computer machine itself cannot. Characteristics of computer Let us identify the major characteristics of computer. These can be discussed under the headings of speed, accuracy, diligence, versatility and memory. 

Speed: - As you know computer can work very fast. It takes only few seconds for calculations that we take hours to complete. You will be surprised to know that computer can perform 1/3 millionth (1/3,000,000) of instructions and even more per second. Therefore, we determine the speed of computer in terms of microsecond (10-6 part of a second) or nano-second (10-9 part of a second). From this you can imagine how fast your computer performs work.

2

M&S PUBLICATIONS  Accuracy: - The degree of accuracy of computer is very high and every calculation is performed with the same accuracy. The accuracy level is determined on the basis of design of computer. The errors in computer are due to human and inaccurate data. 

Diligence: - A computer is free from tiredness, lack of concentration, fatigue, etc. It can work for hours without creating any error. If millions of calculations are to be performed, a computer will perform every calculation with the same accuracy. Due to this capability it overpowers human being in routine type of work.



Versatility: -It means the capacity to perform completely different type of work. You may use your computer to prepare payroll slips. Next moment you may use it for inventory management or to prepare electric bills.



Power of Remembering: -Computer has the power of storing any amount of information or data. Any information can be stored and recalled as long as you require it, for any numbers of years. It depends entirely upon you how much data you want to store in a computer and when to lose or retrieve these data.



No IQ: -Computer is a dumb machine and it cannot do any work without instruction from the user. It performs the instructions at tremendous speed and with accuracy. It is you to decide what you want to do and in what sequence. So a computer cannot take its own decision as you can.



No Feeling: - It does not have feelings or emotion, taste, knowledge and experience. Thus it does not get tired even after long hours of work. It does not distinguish between users.



Storage: -The Computer has an in-built memory where it can store a large amount of data. You can also store data in secondary storage devices such as floppies, which can be kept outside your computer and can be carried to other computers.

History and Generations of computers The history of computer development is often referred to in reference to the different generations of computing devices. A generation refers to the state of improvement in the product development process. This term is also used in the different advancements of new computer technology. With each new generation, the circuitry has gotten smaller and more advanced than the previous generation before it. As a result of the miniaturization, speed, power, and computer memory has proportionally increased. New discoveries are constantly being developed that affect the way we live, work and play. Generations of computers Each generation of computers is characterized by major technological development that fundamentally changed the way computers operate, resulting in increasingly smaller, cheaper and powerful, efficient and reliable devices. Read about each generation and the developments that led to the current devices that we use today. First Generation - 1940-1956: Vacuum Tubes The first computers used vacuum tubes for circuitry and magnetic drums for memory, and were often enormous, taking up entire rooms. A magnetic drum, also referred to as drum, is a metal cylinder coated with magnetic iron-oxide material on which data and programs can be stored. Magnetic drums were once used as a primary storage device but have since been implemented as auxiliary storage devices. They were very expensive to operate and in addition to using a great deal of electricity, generated a lot of heat, which was often the cause of malfunctions. First 3

M&S PUBLICATIONS generation computers relied on machine language to perform operations, and they could only solve one problem at a time. Machine languages are the only languages understood by computers. While easily understood by computers, machine languages are almost impossible for humans to use because they consist entirely of numbers. Computer Programmers, therefore, use either high level programming languages or an assembly language programming. An assembly language contains the same instructions as a machine language, but the instructions and variables have names instead of being just numbers. The UNIVAC and ENIAC computers are examples of first-generation computing devices. The UNIVAC was the first commercial computer delivered to a business client, the U.S. Census Bureau in 1951. Advantages   

Vacuum tubes were the only electronic component available during those days. Vacuum tube technology made possible to make electronic digital computers. These computers could calculate data in millisecond.

Disadvantages               

The computers were very large in size. They consumed a large amount of energy. They heated very soon due to thousands of vacuum tubes. They were not very reliable. Air conditioning was required. Constant maintenance was required. Non-portable. Costly commercial production. Limited commercial use. Very slow speed. Limited programming capabilities. Used machine language only. Used magnetic drums which provide very less data storage. Used punch cards for input. Not versatile and very faulty.

Second Generation - 1956-1963: Transistors Transistors replaced vacuum tubes and ushered in the second generation computer. Transistor is a device composed of semiconductor material that amplifies a signal or opens or closes a circuit. Invented in 1947 at Bell Labs, transistors have become the key ingredient of all digital circuits, including computers. Today's latest microprocessor contains tens of millions of microscopic transistors. Prior to the invention of transistors, digital circuits were composed of vacuum tubes, which had many disadvantages. They were much larger, required more energy, dissipated more heat, and were more prone to failures. It's safe to say that without the invention of transistors, computing as we know it today would not be possible . The examples of second generation computers are IBM 7094 series, IBM 1400 series and CDC 164 etc. Advantages    

Smaller in size as compared to the first generation computers. The 2nd generation Computers were more reliable Used less energy and were not heated. Wider commercial use 4

M&S     

PUBLICATIONS Better portability as compared to the first generation computers. Better speed and could calculate data in microseconds Used faster peripherals like tape drives, magnetic disks, printer etc. Used Assembly language instead of Machine language. Accuracy improved.

Disadvantages      

Cooling system was required Constant maintenance was required Commercial production was difficult

Only used for specific purposes Costly and not versatile Punch cards were used for input.

Third Generation - 1964-1971: Integrated Circuits The development of the integrated circuit was the hallmark of the third generation of computers. Transistors were miniaturized and placed on silicon chips, called semiconductors, which drastically increased the speed and efficiency of computers. A chip is a small piece of semi conducting material (usually silicon) on which an integrated circuit is embedded. A typical chip is less than ¼-square inches and can contain millions of electronic components (transistors). Computers consist of many chips placed on electronic boards called printed circuit boards. There are different types of chips. For example, CPU chips (also called microprocessors) contain an entire processing unit, whereas memory chips contain blank memory. Semiconductor is a material that is neither a good conductor of electricity (like copper) nor a good insulator (like rubber). The most common semiconductor materials are silicon and germanium. These materials are then doped to create an excess or lack of electrons. Computer chips, both for CPU and memory, are composed of semiconductor materials. Semiconductors make it possible to miniaturize electronic components, such as transistors. Not only does miniaturization mean that the components take up less space, it also means that they are faster and require less energy. Instead of punched cards and printouts, users interacted with third generation computers through keyboards and monitors and interfaced with an operating system, which allowed the device to run many different applications at one time with a central program that monitored the memory. Computers for the first time became accessible to a mass audience because they were smaller and cheaper than their predecessors. Advantages          

Smaller in size as compared to previous generations. More reliable. Used less energy Produced less heat as compared to the previous two generations of computers. Better speed and could calculate data in nanoseconds. Used fan for heat discharge to prevent damage. Maintenance cost was low because hardware failure is rear. Totally general purpose Could be used for high-level languages. Good storage 5

M&S     

PUBLICATIONS Versatile to an extent Less expensive Better accuracy Commercial production increased. Used mouse and keyboard for input.

Disadvantages  

Air conditioning was required. Highly sophisticated technology required for the manufacturing of IC chips.

Fourth Generation - 1971-Present: Microprocessors The microprocessor brought the fourth gen...


Similar Free PDFs