COMPUTER TRAINING: C

Monday, 24 December 2012

C

C
C is a general-purposeproceduralimperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unixoperating system.C Logo
It is a high-level programming language that is able to manipulate the computer at a low level like assembly language. During the last half of the 1980s, C became the language of choice for developing commercial software.
has also greatly influenced many other popular languages, especially C++, which was originally designed as an enhancement to C. It is the most commonly used programming language for writing system software, though it is also widely used for writing applications.C, and its object-oriented successor C++, are used to write a huge variety of applications and almost all operating systems.
 
 
 
 
 
Fundamental concept of Problem solving
 
Introduction
 
Firstly we will discuss here Fundamental concept of Problem solving. Then This chapter gives the viewer/reader an overview of C language and tells about the structure of C program and various component of a C program. C language allows us to create custom data types.
 
Problems are the undesirable situations that prevent any software from fully achieving its objectives.
When we wish to transform the existing situation into a more desired one, problem occurs, and a need for solving the problem arises.
 
Defining a problem clearly in terms of goals and objectives helps largely in problem solving.
 
There are three related terms that need to be well understood to successfully solve the problem:
 
1. Mission: It is the broad statement of the purpose of the organization.
 
2. Goals: It is the general statement of what is to be accomplished.
 
3. Objectives: It is the statement of measurable results to be achieved in a specified time frame.
 
 
 
 
Fundamental concept of Problem solving
 
Problem solving strategies
 
The most popular method of problem solving is to divide and conquer. This means that the problem has to be divided into smaller problems, each of which must be solved to get the complete solution.
 
For instance, if it is required to find the second smallest element in an array, the problem could be divided into two parts viz.
 
Arranging the elements in the array in ascending or descending order and then getting the second smallest element form the sorted array.
 
This strategy is called divide and conquer.
 
If you want to find the sum of the digits in a number, it can be divided into 3 parts:
 
1. Finding modulus of 10 i.e. finding the remainder when the number is divided by 10.
 
2. Adding the remainder to a sum whose initial value is zero.
 
3. Dividing the number by 10 and then repeating the process from (1) again till the quotient is zero.
 
 
 
 
Fundamental concept of Problem solving
 
Program design & implementation
 
There are two types of designing approach:
 
1. Top down design.
2. Bottom up design.
 
Both have been describe together with examples.
 
Any problem can be dealt with two ways, viz. top down or bottom up. A simple example is given here to illustrate the concept.
Sorting an array of numbers involves the following two steps:
 
1. Comparison
2. Exchange
 
1. Top down design:
 
At the top level, an algorithm has to be formulated to carry out sorting. Once the algorithmis confirmed, then the algorithms for comparison and exchange are formulated, before implementation of the entire algorithm.
 
Therefore, in this approach, one begins from the top level without bothering about the minute details for implementation, to start with.
 
2. Bottom up design:
 
The bottom up approach is just the reverse. The lower level tasks are first carried out and are then integrated to provide the solution.
 
In this method, lower level structures of the program are developed first and then progressively higher level structures are created.
 
Here the algorithms for exchange and comparison will be formulated before formulating the algorithm for the whole problem.
 
In any case, dividing the problem into small tasks and then solving each task provides the solution.
 
If the program development is assumed to be a single task and the program statements are developed in sequence, then it is quite likely that the program may not work.
 
Therefore, either the top down or bottom up methodology has to be adopted for dividing the problem into smaller modules and then solving it.
 
Difference between Top design and Bottom up approach:
 
In the top down methodology, the overall structure is defined before getting into details, but in the bottom up approach, the details are worked out first before defining the overall structure.
 
Implementation
 
A good program is one which contains a main function and the main function calls procedures or sub-programs or functions to carry out specific tasks.
 
The subprograms are dependent on the main program. They do what the main program asks them to do.
 
Each language gives different names to sub-programs. Sub programs are known as functions in C.
 
The quality of program will also get enhanced when the program is made modular as mentioned above with functions.
 
Each function will receive input and may return some output to the called program.
 
By dividing the problem into a number of functions, the problem can be divided and conquered.
 
This facilities focus on small programs and dealing with one problem at a time.
 
 
 
 

No comments:

Post a Comment