Programming techniques- Computer doesn’t understand your language. It understand only programming languages. So to solve your problem you must program it. It’s on you what language you are choosing. But question arise how to go through programming. For this we can use two techniques-
(1) Flowchart (2) Algorithm
Flowchart – Flowchart is pictorial representation of problem’s solution. In flowchart we use predefined symbols to describe logic of computer program.
A flowchart uses some symbols like oval, parallelogram, rectangle, arrow and connectors.
(a)
Oval – The oval is used for only two purpose : to define beginning point of a flowchart (Start) and to show termination point (END).
(
Parallelogram – The parallelogram is used for input and output operations.
©
Rectangle – The rectangle is used in connection with assignment statement. Assignment statements assign value to a variable. For example int P=1000.
(d)
Arrow – Arrow shows flow of information.
(e)
Diamond – The diamond is used for decision making in a program.
(f)
Connectors – The connector symbol is used to eliminate lines between one part of the flowchart to another.
Now if we want to draw a flowchart for SI, we follow following steps-
(1) Draw oval and write START init.
(2) Draw a parallelogram (connect it with oval with the help of arrow) and write “Input P, R, T” init.
(3) Draw a rectangle (connect it with parallelogram with the help of arrow) and write “Calculate SI=P*R*T/100” init.
(4) Again draw a parallelogram (connect it with rectangle with the help of arrow) and write “Print SI” init.
(5) Draw oval (connect it with parallelogram where Print SI ) and write “Stop” init.
Note : - Picture is attached.
Algorithm- Algorithm is a sequence of precise and unambiguous instructions for solving any problem in a finite no. of operations.
Well we can say, Algorithm is a stepwise approach. Which is precise and to the point. For example you want to make a c program for calculating simple interest while Principle, Rate of interest and Time are already given, then what are the steps involved in it let’s see-
Step – 1 : Input principle, rate and time as P, R, T ( Where P denotes to principle, R denotes to rate of interest and T denotes to Time).
Step – 2 : Use mathematics formula
SI = (p*r*t)/100 to calculate interest. (SI is simple interest).
Step – 3 : Print SI as simple interest.
Step – 4 : Stop.
Another good example is related to student divisions is given below-
Step -1 : Input student total and obtained marks as t and o.
Step – 2: Calculate percentage of student with mathematics formula –
P= (o/t)*100 Here p denotes to percentage.
Step – 3 : If P>=60 then print “I division.”
If P>44 and P<60 then print “II division.”
If P>32 and p<45 and then print “III division.”
Else print “Student is failed.”
Step – 4 : Stop.
Using Turbo c/c++ I run my all c programs in turbo c compiler. For run turbo c compiler, you must go in tc directory of your system by following steps –
CD TC
C:\> TC> CD BIN
C:\TC\BIN>TC
Pressing enter key you will get editing screen of turbo c.
Here are steps for writing and running a program.
(1) Goto File menu select New there. A blank file will be shown where ypu can write your program.
(2) In second step you save your program. For this you will select save option in File menu and save your file as filename.cpp.
(3) Now we ready to compile our program. By compilation, we can check syntax error and warning messages. For compile our program we select compile from Compile menu or press Alt + F9.
(4) Next screen shows success message (If there is no error in your program).
(5) Now for executing your program select Run from Run menu or press Ctrl + F9. Now you can see output of your program.
Reply