#### Series - 1 Logic's For Programming

Series - 1 Logic's For Programming

As we have discussed that logic is quite important while learning and implemnting programming as it creates the plan of action or we can say set the route for the future journey of the pragram or module that we are working on.

important aspect while developing logics for the any module that we are working for is "What we have over here" as then only we can think as what we can get or what we want get with the additional help of conditional statement or the loops like this kind of "Tokens"(which we formally refer in C ).

if we take a basic example for this the if we have two inputs val_1 and val_2 and we need to find addition for this , there are lots of permutations and combinations through we can do this but the addition process will be there as it is what we need to do

declaration val_1,val_2;

/* this can be constant but inputs are important */

input val_1;

input val_2;

sum = val_1 + val_2;

display (sum)

as we can see the basic example of sum , their are always have some steps to build the module this sum programm will not work if we put the sum part before the input value as inputs are necessary .

if we go little further to this then we can inlcudes some statements in to this module as if you came across the project where you have to bifurgate the sum into two parts as if the sum value is above 50 then it would display the "Completed Half Century" then what would we do over here (most of the readers must have solved this).

Their are some techniques or we can say "tokens" that we should know while learning programming (this used to be in our school sylabus "Algorithms") that is conditional statements.

conditional statements includes

1 - if

2 - if-else (nested will slso come under this section only )

3 - switch statements.

For this example we will use if first.

declaration val_1,val_2;

/* this can be constant but inputs are important */

input val_1;

input val_2;

sum = val_1 + val_2;

display (sum)

if (sum>50)

{

print("Completed Half Century");

}

To make this example a bit complex we can include else statement into this.

such as

if (sum>50)

{

print("Completed Half Century");

}else

{

print("Need to complete the Half Centuries");

}

AS THIS IS JUST AS INTRODUCTIONARY EXAMPLE WE WILL NOT MAKE THIS MORE COMPLEX THAN THIS BUT SUERLY WE WILL SE ALOT OF COMPLEX IF-ELSE EXAMPLES.

in similar pattern we will see the Loop example .

now what is the loop and what is the use of this in programming language ?

we will see this one by one .

What is Loop ? Loop is a Cycle , in very simple word we can say that it is a Cycle it has a starting Point where it will start and an end point where it will stop or end .

We will see this by example .

if we want to see the number series which will start from 1 and end at 10 then what we will do. we will apply loop over here .

there are lots of loop examples, viz for loop, do while, while this are some of the prominent onesn but we will not use any significant one

declare a varibale which will hold the loop as Val_1;

starting point Val_1=1;

loop(Val_1<=10)

{

Print(Val_1);

Val_1++;

}

This loop structure is quite similar to while loop as it is a quite simple one to inderstand and for starter is enough.

as we will see this will start from  1 and will end at 10 it will go further at 11 as we have given val_1++ , but as the condition is not permitted it will stop the execution and will display the series value.

As This was the first Example the Content is quite Easy and Small with further course series we will build our content like this but with more Complexity

-EduwithUs Team 