How to Write a Program? Part-1

Photo by Ilya Pavlov on Unsplash

Of course, some steps need to be followed.

But they are not as you think they.

You don’t need to write a pseudo code But still, you need some idea of where you are going. For this, you must first start looking at common problems small ones which can help you get the steps. The steps are not written on any rocks and are always followed based on intuitions.

So, learning to program is mostly you trying to solve a puzzle you can have some steps but its not necessary to follow any of them.

Now the Actual Steps (can be used in any programming language):

  1. Input
  2. Process the input
  3. Output

Each problem can be solved by these 3 steps alone. The implementation depends on the coder himself/herself.

Input

You must know how to take input from the user in any particular language.

Taking input does not require any logic but still, the types of inputs and the way they are provided to you will highly affect your program.

what are the types of inputs you will want when programming a program?

basically, there are three types:

  1. Data to process
  2. Events like clicking or hover (on some UI)
  3. Specifying the type of operation

Data to process

This Data can be numbers or some strings (Text) which need to be computed or altered. This is the normal type of input you can get when making a console-based application.

function add(int a,int b){
return a+b;
}
function ConvertFirstLetterCapital(string str){
changetoCapital(str[0]);
return str;
}

Events

This function or we can say the process will occur when a particular event occurs.

A particular process might use the event data and then give a particular output

function redirectToAParticularPage(){
redirect('./index.html');
}
btn.onClick = redirectToAParticularPage

Specifying the type of operation

Sometimes there are types of inputs that can contain just a type of operation

for example, a calculator process should be provided with the type of operation it needs to do for a particular operation.

function calculator(char operation,int a,int b){
if(operation=='+'){
return add(a,b)
} else if(operation == '-'){
return subtract(a,b)
}
}

Coder who wants to teach the art of coding