Thursday, December 3, 2020

Loops in c language.

 Learn programming for free



Loops in c language.


In c language loops is basically of three types.

  1. For loop
  2. while loop
  3. do while loop

We will learn all of them in depth with a question so that it becomes easy to learn and understand.


Question: Write a program in c language which will take input from user and print all number in between 1 to entered number?


1.For loop


#include<stdio.h>
int main()
{
int n,i=1;
printf("Enter number");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("%d\n",i);
}
return 0;
}


Syntax of for loop is:

for(initialization;condition;increment/decrement)
{
    
        //logic

}

Explanation:

According to question user will enter a number and we need to print all number between 1 to that number.So we take input from user and inside for loop we initialize our for loop to start from 1 and go till entered number.For each iteration we increment i so that when matched conditions found it terminates for loop and comes out of loop.

And for each iteration we have printed the number.


2.While loop


#include<stdio.h>
int main()
{
int n,i=1;
printf("Enter number");
scanf("%d",&n);
while(i<=n)
{
printf("%d",i);
i++;
}
return 0;
}

While loop is also called as entry controlled loop because it first checks the conditions.If conditions found to be true then only it enters in loop otherwise it skips the loop.

So in above example we have first initialize a variable i = 1.And before entering in while loop we checked the condition since 1<=n ( suppose n=10) then it will enter into loop and print that number.

One important point that we should keep in our mind that inside our while loop we must increment our variable otherwise it will lead to infinite loop condition.


3. do-while loop


#include<stdio.h>
int main()
{
int n,i=1;
printf("Enter number");
scanf("%d",&n);
do
{
printf("%d",i);
i++;
}while(i<=n);
return 0;
}


do-while loop is called as exit-controlled loop because it first executes a statement then check conditions.If our initial condition is found to be false then also it will execute for once.That's why it is known as exit-controlled loop. 

If you want to learn c language in depth then do visit: learn c language in depth.

C++ language.

 Learn programming for free


C++ language


C++ is powerful general purpose programming language.It is an extension of c language.It is a mid level programming language.It is used to develop operating system,browsers ,games etc.C++ is very popular programming language.It was developed by Bjarne stroustrup in 1979.


Features of c++.

  1. The most important feature it is object oriented.
  2. It is simple language.
  3. Structured programming language.
  4. Powerful and fast.
  5. Most secure and fast than C.
  6. Platform dependent.
  7. Memory management.

We will discuss each topic of C++ in depth.We will discuss topic wise so that you can understand each topic in depth and with clarity.


Topics:






Getting started with C++.

 Learn programming for free


Getting started with C++.


In this blog we will learn about fundamentals of C++.For example how to take input,how to print output etc.This is what every student who wants to learn c++ should definitely know.


So let's understand all these things with very basic example:


#include<iostream>
using namespace std;
int main()
{
int a,b,sum=0;
cout<<"Enter first number";
cin>>a;
cout<<"Enter second number";
cin>>b;
sum=a+b;
cout<<"Sum is"<<sum;
return 0;
}


Above program is used to find sum of two number in c++.Now understand each line of above code in detail.

1. #include<iostream>

In programming language we call it as header file,which includes all details required to carry out current program.Like in our case we are taking two input from user so this header file includes all functionalities required to take input from user.


2.using namespace std

Here this line is used so that we can use all standard things in c++.

For example if  we don't use this line then for writing cin we have to write syntax as

std::cin>>

otherwise we write syntax as cin>>


3.int main()


This is a function don't worry we will learn it in depth here just remember it that it is simply a function.


4.cout<<"Enter first number";

This statement is used to print  information on screen.Like in our case it is will print Enter first number.


5.cin>>a;


This statement is used to take input from user.In our case it will take input from user as an integer.


6.sum = a+b;

I don't think this statement needs any explanation.This is a simple arithmetic operation.It will store sum of a and b into sum variable.

7. Finally it will print sum of two number as a result.


If you want to learn c language in depth then do visit : learn c language in depth.

 

Getting started with C language.

 Learn programming for free


Getting started with C language.


In this blog we will learn basic of c language like how to take input,how to print output etc.These are very basic things that every student should know before moving on.

I will explain all these thing with very basic example,which is easy to understand.


#include<stdio.h>

int main()

{

int a,b,sum=0;

printf("Enter first number");

scanf("%d",&a);

printf("Enter second number");

scanf("%d",&b);

sum=a+b;

printf("Sum of two number is %d",sum);

return 0;

}


Explanation:

This is a simple program which takes two number from user and print their sum as a result.


  1. #include<stdio.h>


In programming language we call it as a header file.This header files includes all information required to carry out our particular program.


Like in our case it is included because we need to take input from user and print output.

      

    2. int main()


This is a function don't worry we will learn it in depth here just remember it that it is simply a function.

      

    3. printf();


This statement is used to print  information on screen.Like in our case it is will print Enter first number.

      

    4. scanf();


This statement is used to take input from user.In our case it will take input from user as an integer.

      

    5. sum = a+b;


I don't think this statement needs any explanation.This is a simple arithmetic operation.It will store sum of a and b into sum variable.

      

    6. Finally it will print sum of two number as a result.








       






C language

 Learn programming for free


C language

C is powerful general purpose programming language.It was developed by Dennis Ritchie in 1972.It used for many purpose like developing system software,operating system,compilers etc.It was initially used for developing system works.C language is procedural programming language using top-down approach.


In this blog you will get to learn all topics of  c language in depth.Here we have divided it into topics so that it will be ease for user to learn faster.


Features of c language:

  1. It is general purpose programming language.
  2. Modularity.
  3. Fast and efficient. 
  4. Mother of C++ programming language.
  5. It is mid level programming language.
  6. Rich in libraries and functions.
  7. It is simple,machine independent.
  8. Portable.

Topics:


Wednesday, December 2, 2020

Programming.

Learn programming for free

                                      

Programming.

To communicate with computer we must know a programming languae.It's just like how we human being communicate with each other likewise to communicate with computer we must know a programming language.


So basically we should know what is a programming language?

Program is basically instructions given to computer to perform a specific task.For example let's understand this with an example,suppose we want to find factorial of a given number.So we must give instructions to computer to fins factorial of a given number.

There are many programming language but in this blog we will discuss C/C++  perform our specific task.

C is basically a superset of C++.


C language.

This is a programming language that every programmer must be aware from.C language initially used to develop system work.C is powerful general purpose programming language.It is used to develop operating system,compilers,database.It is a procedural programming language.


Features of C:
  1. It is general purpose programming language.
  2. Modularity.
  3. Fast and efficient. 
  4. Mother of C++ programming language.
  5. It is mid level programming language.
  6. Rich in libraries and functions.
  7. It is simple,machine independent.
  8. Portable.

It was developed by Dennis Ritchie in 1972.

                                               

C++ language  

 

As discussed above C language is super set of C++ that means C++ is an extension of C language.It is also a mid level programming language.It is a powerful general purpose programming language used to develop operating system,browser,games etc.


      Features of C++

  1. The most important feature it is object oriented.
  2. It is simple language.
  3. Structured programming language.
  4. Powerful and fast.
  5. Most secure and fast than C.
  6. Platform dependent.
  7. Memory management.

It was developed by Bjarne Stroustrup in 1979.

Tuesday, December 1, 2020

Learn programming for free

Learn programming for free


Welcome to learn programming for free. In this blog you will widen your knowledge from fundamental programming to advance web development.All tutorials has been created by keeping in mind from user prospectives.As we all know we are living in computer science era.Computer has become an integral part of our life.Computer are being used in all sphere of life ranging from home automation to aerospace science.So now comes to point in this blog we will discuss following topics in depth.




1. Programming

This is fundamental part that every computer science student should know before moving to advance topics in computer science. In this part of course we will discuss the fundamentals of programming language. We will discuss C/C++ programming language.


But wait !  till now we haven't discuss what is a programming language. Like we human being understand a language likewise to communicate with computer we should know programming language. Basically program is instruction given to computer to perform a specific task. For example we want computer to calculate what is 2+2 for us. So to do that we should give instructions to computer to do the same.



I hope now you all are aware from what a program is


Like we human being understand different languages there are different programming laguage also. But in this course we will basically discuss C/C++programming language in depth. C is superset of C++.Don't worry we will discuss in depth all concepts.



2.Data structures and algorithms

Now moving forward we are now in a position from where we can now move to advance concepts of computer science i.e data structures and algorithms. Here we will discuss all fundamentals of data structures and algorithms from basic to advance. This is also something that every computer science student should we aware of. Now we are in journey to learn advance concepts.


3.Web development


Since we are now comfortable with fundamentals of computer science now we are in our journey to become a full stack web developer. Before knowing what is a full stack web developer or what work a full stack developer does,we should know what is frontend and backend



What is frontend?


Let's understand it with very simple example we all are aware from facebook,when we type facebook.com in our web browser it redirects us to official website of facebook.Where it wither tells us to login or signup.This is frontend part of facebook.So basically frontend part communicate with clients. The part which communicate with client is called as frontend part.


What is backend?



Let's continue with our facebook example while we enter our details like name,email,password. We must imagine where all these data goes. All these data gets stored inside a database. So that again when we logged in, facebook can authenticate a valid user and must identifies every user as independent identity.

So this part come into playing with data. This is what a backend developer does.


So know i hope you all must be aware from frontend and backend part in brief. Now come to our main topic we should now in position to know what is a full stack we developer. So a developer which can handle both frontend and backend part is called as a full stack web developer. This is what we will cover in this course.



4.Programs

Knowing only theory part is not enough we must know how to implement them also .So in this part of the course we will discuss programs on different topics to strength your theory concept.



Hoping to see you again in this course again