About The Tutorial

3y ago
159 Views
8 Downloads
844.25 KB
21 Pages
Last View : 1d ago
Last Download : 3m ago
Upload by : Fiona Harless
Transcription

About the TutorialComputer programming is the act of writing computer programs, which are asequence of instructions written using a Computer Programming Language toperform a specified task by the computer.Computer Programming is fun and easy to learn provided you adopt a properapproach. This tutorial attempts to cover the basics of computer programmingusing a simple and practical approach for the benefit of novice learners.AudienceThis tutorial has been prepared for the beginners who are willing to learn computerprogramming but they are unable to learn it due to lack of proper guidance. Weare confident that after completing this tutorial, you will be at a level where youcan code in C Programming language and will have a basic understanding of Javaand Python programming languages as well from where you can continue further.If you are completely new to Computer Programming, then we recommend you toread this tutorial twice or even thrice. First reading will not give you much idea,but during your second reading, you will start grasping most of the concepts andyou will enjoy writing computer programs.PrerequisitesWe do not expect much from you as prerequisites, however, we assume that youhave some amount of exposure to computers and its peripherals like keyboard,mouse, screen, printer, etc.Copyright & Disclaimer Copyright 2014 by Tutorials Point (I) Pvt. Ltd.All the content and graphics published in this e-book are the property of TutorialsPoint (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy,distribute or republish any contents or a part of contents of this e-book in anymanner without written consent of the publisher.We strive to update the contents of our website and tutorials as timely and asprecisely as possible, however, the contents may contain inaccuracies or errors.Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy,timeliness or completeness of our website or its contents including this tutorial. Ifyou discover any errors on our website or in this tutorial, please notify us atcontact@tutorialspoint.comTable of ContentsAbout the Tutorial ········ ii

Audience ······················· iPrerequisites ················· iCopyright & Disclaimer · iTable of Contents ········· ii1. ···· 1Introduction to Computer Program ······· 1Introduction to Computer Programming ························ 2Uses of Computer Programs ················· 2Computer Programmer ························· 3Algorithm ····················· 32. BASICS ······ 53. �······················· 7Text Editor ··················· 8Compiler ······················ 8Interpreter ··················· 9Online Compilation ···· 104. BASIC ····················· 11Hello World Program in �···················· 11Syntax Error ··············· 15Hello World Program in Java ··············· 15Hello World Program in Python ·········· 165. DATA TYPES ····················· 17C and Java Data Types ························· 18Python Data Types ····· 196. VARIABLES ······················· 20ii

Creating variables ······ 20Store Values in Variables ···················· 21Access Stored Values in Variables ······· 22Variables in Java ········ 23Variables in Python ···· 247. KEYWORDS ······················ 26C Programming Reserved Keywords ··· 27Java Programming Reserved Keywords ························ 27Python Programming Reserved Keywords ··················· 288. OPERATORS ····················· 30Arithmetic Operators · 30Relational Operators ·· 32Logical Operators ······· 34Operators in Java ······· 36Operators in ······ 379. DECISION STATEMENTS ··· 39if.else statement ······ 41if.else if.else statement ··················· 42The switch statement ························· 44Decisions in Java ········ 46Decisions in Python ···· 4710. LOOPS ···· 48The while ············· 50The do.while Loop ··· 51The break statement ·· 53The continue statement ······················ 54iii

Loops in Java ·············· 56Loops in Python ········· 5611. NUMBERS ······················· 58Math Operations on Numbers ············ 59Numbers in ··········· 62Numbers in Python ···· 6312. CHARACTERS ··················· 65Escape Sequences ······ 66Characters in Java ······ 68Characters in Python ·· 6913. ARRAYS ·· 70Create Arrays ············· 71Initializing Arrays ······· 71Accessing Array Elements ··················· 72Arrays in Java ············· 73Arrays (Lists) in Python ······················· 7414. STRINGS · 76Basic String Concepts · 79Strings in Java ············ 79Strings in Python ········ 8015. FUNCTIONS ····················· 81Defining a Function ···· 83Calling a Function ······· 83Functions in Java ········ 85Functions in Python ··· 86iv

16. FILE �···· 88Computer Files ··········· 88File Input/Output ······· 88File Operation Modes ························· 88Opening Files ············· 89Closing a File ·············· 90Writing a ················ 90Reading a File ············· 91File I/O in Java ··········· 92File I/O in Python ······· 9317. �· 95v

1. OVERVIEWIntroduction to Computer ProgramBefore getting into computer programming, let us first understand computerprograms and what they do.A computer program is a sequence of instructions written using a ComputerProgramming Language to perform a specified task by the computer.The two important terms that we have used in the above definition are: Sequence of instructions Computer Programming LanguageTo understand these terms, consider a situation when someone asks you about howto go to a nearby KFC. What exactly do you do to tell him the way to go to KFC?You will use Human Language to tell the way to go to KFC, something as follows:First go straight, after half kilometer, take left from the red light andthen drive around one kilometer and you will find KFC at the right.Here, you have used English Language to give several steps to be taken to reachKFC. If they are followed in the following sequence, then you will reach KFC:1.Go straight2.Drive half kilometer3.Take left4.Drive around one kilometer5.Search for KFC at your right sideNow, try to map the situation with a computer program. The above sequence ofinstructions is actually a Human Program written in English Language, whichinstructs on how to reach KFC from a given starting point. This same sequence couldhave been given in Spanish, Hindi, Arabic, or any other human language, providedthe person seeking direction knows any of these languages.6

Now, let's go back and try to understand a computer program, which is a sequenceof instructions written in a Computer Language to perform a specified task by thecomputer. Following is a simple program written in Python programming Language:print "Hello, World!"The above computer program instructs the computer to print "Hello, World!" on thecomputer screen. A computer program is also called a computer software, which can rangefrom two lines to millions of lines of instructions. Computer program instructions are also called program source code andcomputer programming is also called program coding. A computer without a computer program is just a dump box; it is programsthat make computers active.As we have developed so many languages to communicate among ourselves,computer scientists have developed several computer-programming languages toprovide instructions to the computer (i.e., to write computer programs). We will seeseveral computer programming languages in the subsequent chapters.Introduction to Computer ProgrammingIf you understood what a computer program is, then we will say: the act of writingcomputer programs is called computer programming.As we mentioned earlier, there are hundreds of programming languages, which canbe used to write computer programs and following are a few of them: Java C C Python PHP Perl Ruby7

Uses of Computer ProgramsToday computer programs are being used in almost every field, household,agriculture, medical, entertainment, defense, communication, etc. Listed below area few applications of computer programs: MS Word, MS Excel, Adobe Photoshop, Internet Explorer, Chrome, etc., areexamples of computer programs. Computer programs are being used to develop graphics and special effects inmovie making. Computer programs are being used to perform Ultrasounds, X-Rays, and othermedical examinations. Computer programs are being used in our mobile phones for SMS, Chat, andvoice communication.Computer ProgrammerSomeone who can write computer programs or in other words, someone who can docomputer programming is called a Computer Programmer.Based on computer programming language expertise, we can name a computerprogrammers as follows: C Programmer C Programmer Java Programmer Python Programmer PHP Programmer Perl Programmer Ruby ProgrammerAlgorithmFrom programming point of view, an algorithm is a step-by-step procedure toresolve any problem. An algorithm is an effective method expressed as a finite set ofwell-defined instructions.8

Thus, a computer programmer lists down all the steps required to resolve a problembefore writing the actual code. Following is a simple example of an algorithm to findout the largest number from a given list of numbers:1.Get a list of numbers L1, L2, L3.LN2.Assume L1 is the largest,3.Take next number Li from the list and do the following4.If Largest is less than Li5.Largest Li6.If Li is last number from the list then7.Print value stored in Largest and come out8.Else repeat same process starting from step 3Largest L1The above algorithm has been written in a crude way to help beginners understandthe concept. You will come across more standardized ways of writing computeralgorithms as you move on to advanced levels of computer programming.9

2. BASICSWe assume you are well aware of English Language, which i

Computer programming is the act of writing computer programs, which are a sequence of instructions written using a Computer Programming Language to perform a specified task by the computer. Computer Programming is fun and easy to learn provided you adopt a proper approach. This tutorial attempts to cover the basics of computer programming

Related Documents:

May 02, 2018 · D. Program Evaluation ͟The organization has provided a description of the framework for how each program will be evaluated. The framework should include all the elements below: ͟The evaluation methods are cost-effective for the organization ͟Quantitative and qualitative data is being collected (at Basics tier, data collection must have begun)

Silat is a combative art of self-defense and survival rooted from Matay archipelago. It was traced at thé early of Langkasuka Kingdom (2nd century CE) till thé reign of Melaka (Malaysia) Sultanate era (13th century). Silat has now evolved to become part of social culture and tradition with thé appearance of a fine physical and spiritual .

On an exceptional basis, Member States may request UNESCO to provide thé candidates with access to thé platform so they can complète thé form by themselves. Thèse requests must be addressed to esd rize unesco. or by 15 A ril 2021 UNESCO will provide thé nomineewith accessto thé platform via their émail address.

̶The leading indicator of employee engagement is based on the quality of the relationship between employee and supervisor Empower your managers! ̶Help them understand the impact on the organization ̶Share important changes, plan options, tasks, and deadlines ̶Provide key messages and talking points ̶Prepare them to answer employee questions

Dr. Sunita Bharatwal** Dr. Pawan Garga*** Abstract Customer satisfaction is derived from thè functionalities and values, a product or Service can provide. The current study aims to segregate thè dimensions of ordine Service quality and gather insights on its impact on web shopping. The trends of purchases have

Chính Văn.- Còn đức Thế tôn thì tuệ giác cực kỳ trong sạch 8: hiện hành bất nhị 9, đạt đến vô tướng 10, đứng vào chỗ đứng của các đức Thế tôn 11, thể hiện tính bình đẳng của các Ngài, đến chỗ không còn chướng ngại 12, giáo pháp không thể khuynh đảo, tâm thức không bị cản trở, cái được

Le genou de Lucy. Odile Jacob. 1999. Coppens Y. Pré-textes. L’homme préhistorique en morceaux. Eds Odile Jacob. 2011. Costentin J., Delaveau P. Café, thé, chocolat, les bons effets sur le cerveau et pour le corps. Editions Odile Jacob. 2010. Crawford M., Marsh D. The driving force : food in human evolution and the future.

Le genou de Lucy. Odile Jacob. 1999. Coppens Y. Pré-textes. L’homme préhistorique en morceaux. Eds Odile Jacob. 2011. Costentin J., Delaveau P. Café, thé, chocolat, les bons effets sur le cerveau et pour le corps. Editions Odile Jacob. 2010. 3 Crawford M., Marsh D. The driving force : food in human evolution and the future.