This question may be very silly for those who have studied several programming languages and have become experts. But, a majority of people from different backgrounds still have no idea of what a programming language is and how to solve a problem using a programming language. While I was working with Aptech computer education centre as a faculty, I came across several students from different backgrounds aged between 18 and 60 years of age. A basic teaching method was to give an overall idea of the needs of programming and the several phases encountered in getting the end result.
The usual definition of programming is writing the instructions step by step for solving a problem in a language that is understood by the computer. Problems need not be from Mathematics or Commerce. They can be from anything in real life, like managing school records, paying a bill or finding the exact color for the décor of your apartment. Just like we complete tasks in our daily life, we can solve these problems with a clear-cut idea of writing the steps involved from the beginning to the end. By learning the various terminologies built in a programming language, these instructions can be written in that syntax. Then they are compiled and executed for the final results. Problem solving includes the following three steps.
1.Identifying the problem
The problem needs to be understood clearly as to reach the objective without making any loop holes. In this step, we identify the kinds of input required for the right output. For all inputs, there must be an output that is valid. A simple example can explain this very well. Consider the addition of two integers 6 and 2. The sum should be 8. But, what if you input the numbers as 2.5 and 2? The result is 4.5, but, as this is a question of addition of integers, one of the inputted numbers is invalid. In such case, computer should display the message, “invalid input”. Identification and analysis are the crux for solving the problem.
2.Writing the instructions step-by-step
Once the problem is identified, you can start writing the instructions in a step-by-step manner. Any violation in maintaining the order can lead to errors and therefore, you should think logically before writing any instruction. An example to reflect this fact is, suppose you have to print two names in two lines with same alignment. Merely writing the instruction as “print “George, Davis”” would print the two names adjacent without moving to the next line. Here, the command should be
This will cause the compiler to move one line before writing the second name.
The program in C result
The step-by-step formation of instructions strongly influences problem solving.
Now, you need to test the whole set of instructions written for execution. Testing can unlock the errors occurred in forming the instructions. Correct the errors by re-ordering or inserting or deleting instructions so that the final result is obtained error-free. Check for all kinds of inputs and validate.
There are several programming languages that enable you to write code for your problem. Their compilers would highlight the errors by giving directions for de-bugging. Before starting to write the code, you’ve to be familiar with the syntax of a programming language. Generally, it is not much different from English language. Modifiers, keywords, variables, operators, conditional and loop structures, operators, functions and files together describe a language with its own syntax. After acquiring knowledge about them, you can start writing your own code for any problem concerned.
C and C++ are the vast-covering programming languages from several areas. C is traditional programming language which is highly portable. It has the ability to run in different computers and operating systems. With a rich set of built-in functions and libraries, C is very useful in writing system-level as well as application level programs. The property of modular programming makes C a highly structured language. C++ is an extension of C with the addition of object-oriented programming. Here, classes and objects define the data types used in the program. The main advantage of using C++ is that it avoids data redundancy and supports data hiding. Learning C++ is like mastering all computer languages.