Showing posts with label Programs. Show all posts
Showing posts with label Programs. Show all posts
Computer Programming Overview

Computer Programming Overview

I assume today is your first day when you heard about computer programming. You are curious to know what exactly is computer programming? Before you understand what is computer programming, you need to understand what is computer program?
I'm making an assumption that you know a little about what is computer and how to use it for Internet browsing, Exploring Facebook or Checking e-mail using Gmail, etc.

What is Computer Program?

A computer program is a sequence of instructions written using a Computer Programming Language to perform a specified task by the computer
I assume, you did not understand what I have written about computer program but let’s see two important terms, which I have used in the above definition:
  • Sequence of instructions
  • Computer Programming Language
To understand these terms, consider a situation when someone asks you about how to 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 and then 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 reach to KFC. If they will be followed in the following sequence, then you will reach KFC:
1.	Go straight
2. Drive half kilometer
3. Take left
4. Drive around one kilometer
5. Search for KFC at your right side
Now, try to map the situation with computer program. Above sequence of instructions is actually a Human Program written in English Language, which instructs on how to reach to KFC from a given starting point. This same sequence could have been given in Spanish Language, Hindi Language, Arabic or any other human language provided someone, who is asking about the way, knows about such languages.
Now, let's go back and try to understand about a computer program, which is a sequence of instructions written in a Computer Language to perform a specified task by the computer. Following is a simple program written in Pythonprogramming Language:
print "Hello, World!"
Above computer program instructs computer to print "Hello, World!" on computer screen.
  • A computer program is also called a computer software, which can range from 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 machine without a computer program is just a dump box and thus computer program brings a computer machine to live state.
Like human has several languages to communicate their message, computer scientists have developed several computer-programming languages to provide instructions to the computer (i.e., to write computer programs). We will see several computer programming languages in subsequent chapters.

What is Computer Programming?

If you understood what is computer program, then I will say the act of writing computer programs is called computer programming.
As I mentioned earlier, there are 100s of programming languages, which can be used to write computer programs and following are few of them:
  • Java
  • C
  • C++
  • Python
  • PHP
  • Perl
  • Ruby

What Computer Program can do?

Today computer programs are being used in almost every field, household, agriculture, medical, entertainment, defense, communication, etc. Following are few applications of computer programs:
  • MS Word, MS Excel, Adobe Photoshop, Internet Explorer, Chrome, etc., are example of computer programs.
  • Computer programs are being used to develop graphics and special effects in movie making.
  • Computer programs are being used to perform Ultrasounds, X-Rays, and other medical examinations.
  • Computer programs are being used in our mobile phones for SMS, Chat, and voice communication.

Who is Computer Programmer?

If you understood what is computer program and what is computer programming, then simply apply common sense to understand who is computer programmer?
Someone, who can write computer programs or in other words, someone who can do computer programming is called Computer Programmer
Based on computer programming language expertise, we can name computer programmers as follows:
  • C Programmer
  • C++ Programmer
  • Java Programmer
  • Python Programmer
  • PHP Programmer
  • Perl Programmer
  • Ruby Programmer

What is Algorithm?

From programming point of view, an algorithm is a step-by-step procedure to resolve any problem. An algorithm is an effective method expressed as a finite set of well-defined instructions.
Thus, a computer programmer lists down all the steps required to resolve a problem before jumping to write actual code. Following is a simple example of an algorithm to find out a largest number from a given list of numbers:
1.      Get a list of numbers L1, L2, L3....LN
2. Assume L1 is the largest, Largest = L1

3. Take next number Li from the list and do the following
4. If Largest is less than Li
5. Largest = Li
6. If Li is last number from the list then
7. Print value stored in Largest and come out
8. Else repeat same process starting from step 3
Above algorithm has been written in very crude way just because to make it clear to beginners, otherwise if you will study computer algorithm subject then you will find standardized way of writing computer algorithm.
Discuss Computer Programming

Discuss Computer Programming

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 will take you through simple and practical approach while learning computer programming.
Computer Programming Data Types

Computer Programming Data Types

Let's discuss about a very simple but very important concept available in almost all the programming languages which is called data types. As its name indicates, a data type represents a type of the data which you can process using your computer program. It can be numeric, alphanumeric, decimal, etc.
Apart from Computer Programming, let's take a nursery class problem to add two whole numbers 10 & 20, which we can do simply as follows:
10 + 20
Let's take another problem where we want to add two decimal numbers 10.50 & 20.50, which will be written as follows:
10.50 + 20.50
Above two examples are straight forward now let's take one example where we want to record student information in a notebook. Here is following important information, which we can record:


  • Name:



  • Class:



  • Section:



  • Age:



  • Sex:



Now, let's put one student record as per the given requirement:


  • Name: Zara Ali



  • Class: 6th



  • Section: J



  • Age: 13



  • Sex: F



First example dealt whole numbers and second example added two numbers with decimals where as third example is dealing with a mix of different data. Let's put it as follows:
  • Student name "Zara Ali" is a sequence of characters which is also called a string.
  • Student class "6th" has been represented by a mix of whole number and a string of two characters. Such a mix is called alphanumeric.
  • Student section has been represented by single character which is 'J'.
  • Student age has been represented by whole number which is 13.
  • Student sex has been represented by a single character which is 'F'.
This way we realized that in our day-2-day life we deal with different types of data like strings, characters, whole numbers which is also called integers, decimal numbers which is also called floating point numbers.
Similar way when we write our computer program to process different types of data, we need to specify its type clearly otherwise computer does not understand how different operations can be performed on that given data. Different programming languages use different keywords to specify different data types. For example C and Java programming languages use int to specify integer data whereas char specifies a character data type.
Subsequent chapters will show you how to use different data types in different situations. For now let's check what are the important data types available in C, Java and Python programming languages and what are the keywords we will use to specify those data types.

C & Java Data Types

Programming languages C and Java support almost same set of data types, though Java supports additional data types. For now, we are taking few common data types supported by both the programming languages:
TypeKeywordValue range which can be represented by this data type
Characterchar-128 to 127 or 0 to 255
Numberint-32,768 to 32,767 or -2,147,483,648 to 2,147,483,647
Small Numbershort-32,768 to 32,767
Long Numberlong-2,147,483,648 to 2,147,483,647
Decimal Numberfloat1.2E-38 to 3.4E+38 till 6 decimal places
These data types are called primitive data types and you can use these data types to build more complex data types, which are called user-defined data type, for example a string will be a sequence of characters.

Python Data Types

Python has five standard data types but this programming language does not make use of any keyword to specify a particular data type rather Python is intelligent enough to understand given data type automatically.
  • Numbers
  • String
  • List
  • Tuple
  • Dictionary
Here, Number specifies all types of numbers including decimal numbers and string represents a sequence of characters with a length of 1 or more characters. For now, let's proceed with these two data types and skip List, Tuple and Dictionary, which are advanced data types in Python.
Computer Programming Basics

Computer Programming Basics

I assume you are well aware of English Language, which is a well-knownHuman Interface Language. English has a predefined grammar, which needs to be followed to write English statements in a correct way. Likewise, most of the Human Interface Languages (Hindi, English, Spanish, French, etc.) are made of several elements like verbs, nouns, adjectives, adverbs, propositions, and conjunctions, etc.
Similar to Human Interface Languages, Computer Programming Languages are also made of several elements. I will take you through the basics of those elements and put some effort to make you comfortable to use them in various programming languages. These basic elements are:
  • Programming Environment
  • Basic Syntax
  • Data Types
  • Variables
  • Keywords
  • Basic Operators
  • Decision Making
  • Loops
  • Numbers
  • Characters
  • Arrays
  • Strings
  • Functions
  • File I/O
I will explain all these elements in subsequent chapters with examples using different programming languages. First we will try to understand meaning of all these terms in general and then we will see how these terms can be used in different programming language.
I believe if you understood above-mentioned elements related to any programming language, then you are almost ready to write big enough programs in that programming language.
I designed this tutorial to give you an idea about the following most popular programming languages:
  • C Programming
  • Java Programming
  • Python Programming
Major part of the tutorial has been explained by taking C as programming language and then I tried to show how similar concepts work in Java and Python. So after completion of this tutorial, you will find yourself familiar with these popular programming languages.

Computer Programming Overview

Computer Programming Overview

I assume today is your first day when you heard about computer programming. You are curious to know what exactly is computer programming? Before you understand what is computer programming, you need to understand what is computer program?
I'm making an assumption that you know a little about what is computer and how to use it for Internet browsing, Exploring Facebook or Checking e-mail using Gmail, etc.

What is Computer Program?

A computer program is a sequence of instructions written using a Computer Programming Language to perform a specified task by the computer
I assume, you did not understand what I have written about computer program but let’s see two important terms, which I have used in the above definition:
  • Sequence of instructions
  • Computer Programming Language
To understand these terms, consider a situation when someone asks you about how to 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 and then 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 reach to KFC. If they will be followed in the following sequence, then you will reach KFC:
1.	Go straight
2. Drive half kilometer
3. Take left
4. Drive around one kilometer
5. Search for KFC at your right side
Now, try to map the situation with computer program. Above sequence of instructions is actually a Human Program written in English Language, which instructs on how to reach to KFC from a given starting point. This same sequence could have been given in Spanish Language, Hindi Language, Arabic or any other human language provided someone, who is asking about the way, knows about such languages.
Now, let's go back and try to understand about a computer program, which is a sequence of instructions written in a Computer Language to perform a specified task by the computer. Following is a simple program written in Pythonprogramming Language:
print "Hello, World!"
Above computer program instructs computer to print "Hello, World!" on computer screen.
  • A computer program is also called a computer software, which can range from 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 machine without a computer program is just a dump box and thus computer program brings a computer machine to live state.
Like human has several languages to communicate their message, computer scientists have developed several computer-programming languages to provide instructions to the computer (i.e., to write computer programs). We will see several computer programming languages in subsequent chapters.

What is Computer Programming?

If you understood what is computer program, then I will say the act of writing computer programs is called computer programming.
As I mentioned earlier, there are 100s of programming languages, which can be used to write computer programs and following are few of them:
  • Java
  • C
  • C++
  • Python
  • PHP
  • Perl
  • Ruby

What Computer Program can do?
Today computer programs are being used in almost every field, household, agriculture, medical, entertainment, defense, communication, etc. Following are few applications of computer programs:
  • MS Word, MS Excel, Adobe Photoshop, Internet Explorer, Chrome, etc., are example of computer programs.
  • Computer programs are being used to develop graphics and special effects in movie making.
  • Computer programs are being used to perform Ultrasounds, X-Rays, and other medical examinations.
  • Computer programs are being used in our mobile phones for SMS, Chat, and voice communication.

Who is Computer Programmer?

If you understood what is computer program and what is computer programming, then simply apply common sense to understand who is computer programmer?
Someone, who can write computer programs or in other words, someone who can do computer programming is called Computer Programmer
Based on computer programming language expertise, we can name computer programmers as follows:
  • C Programmer
  • C++ Programmer
  • Java Programmer
  • Python Programmer
  • PHP Programmer
  • Perl Programmer
  • Ruby Programmer

What is Algorithm?

From programming point of view, an algorithm is a step-by-step procedure to resolve any problem. An algorithm is an effective method expressed as a finite set of well-defined instructions.
Thus, a computer programmer lists down all the steps required to resolve a problem before jumping to write actual code. Following is a simple example of an algorithm to find out a largest number from a given list of numbers:
1.      Get a list of numbers L1, L2, L3....LN
2. Assume L1 is the largest, Largest = L1
3. Take next number Li from the list and do the following
4. If Largest is less than Li
5. Largest = Li
6. If Li is last number from the list then
7. Print value stored in Largest and come out
8. Else repeat same process starting from step 3
Above algorithm has been written in very crude way just because to make it clear to beginners, otherwise if you will study computer algorithm subject then you will find standardized way of writing computer algorithm.

Kategori

Kategori