Tuesday, 20 December 2016

First C programme

So guys Today we will learn some basic programs in C or C++
Please don't be panic, it's not hard as many think specially beginners.

let's start with a basic program of a simple calculator in C
And if u don't know programming or a have just started programming then probably this is the best place
for u people. I will explain the program as well as basics of C (programming). And ya I know you have just started programming..


Lets have the programme

But before starting the programme let's try to imagine what we have to do in the programme.
Easy guess a calculator will perform add, subtract, blaw, blaw...
But how we will perform it now in the very beginning.
Remember that we don't know how to give user's option like select any option with keyboard and mouse.
Because it's the beginning. So now in the Short time we can perform it with simple inputs from the user.
So like in our programme first we will take two inputs from the user means this is the number or the operands
(Operands are those on which operation is performed) and then we will ask the user (i.e. who is using the program don't laugh now it's u only)
to enter some numbers like 1 for adding those previously input numbers, likewise 2 for subtracting, 3 for multiplying, 4 for dividing.
So as per the users choice if user chooses to add i.e. enter 1 then we will print the sum in the screen.
So here we go

// This is a single line comment
/* This is many line comments
Comments are used by programmers to keep some note for other
programmers or for themselves too.
It is the part in the code which is not executed
So here ends many line comments */

#include<stdio.h>
/* So basically we use #include<stdio.h>
So stdio.h is a file which is to be included before the programme compiles
And we are including this file because it contains information of some keywords
which we will use in the programme like printf, scanf
as we don't understand a new word like wise a computer
too don't understand anything  unless specified
so this files are called header files with the extension '.h' */

/*It is the main part of the programme
Because it is the only part which is being executed by the compiler
Compiler: A compiler is a programme which converts the programs to
such a way that a machine can understand it.
So remember if the code does not contain main function then
the programme is not going to be executed */

int main()
{
int choice;
/* Defining a variable called 'choice'. A variable is a named location
of some memory in the computer or it is a portion of a memory to which
we have given name as choice. You can choose anything in variable but
it must start with underscore `_` or a latter, it must not start with a
number and since special characters too are not allowed in declaring a
variable name.
So here in the code snippet we have written int which signifies that the
value which will be stored in the variable if a integer.
Similarly for characters we use `char`, for floating point decimal numbers
we use float etc. */
float a, b, result;

/* printf is a function with which we print something in the screen.
And as specified earlier that its definitions is in the header file stdio.h */
printf("Enter Your Choice");

/* Remember: \n is user for new line character so that after this `\n` anything written will be printed in the new line */
printf("\n1. Add");
printf("\n1. Subtract");
printf("\n1. Multiply");
printf("\n1. Divide");

/* scanf for taking inputs from the user and remember choice is the variable name in which we are storing the value entered by the user.
We have used &choice instead of choice because we are assigning the input value to the variable choice */
scanf("%d", &choice);

printf("\nNow enter two numbers");
scanf("%f", &a);
scanf("%f", &b);

/* No explanation needed if else. Means if the condition specified in the if() is true the part of the code written in the { } will be executed
Otherwise the else part will be executed
Remember that `=` and `==` are two different things
`=` means the right hand side value will be assigned to the left hand side variable
like a = 2;
whereas `==` means if both the two are equals or not */
if (choice == 1)
{
result = a + b;
printf("%f", result);
/* So inputting 1 means we need to add  the numbers and likewise for all and then printing it in the screen */
} else if (choice == 2)
{
result = a - b;
printf("%f", result);
} else if (choice == 3)
{
result = a * b;
printf("%f", result);
} else if (choice == 4)
{
result = a / b;
printf("%f", result);
} else
{
printf("Wrong Choice");
}
return 0;
}


So the final program is
#include <stdio.h>

int main()
{
int choice;
float a, b, result;

printf("Enter Your Choice");
printf("\n1. Add");
printf("\n1. Subtract");
printf("\n1. Multiply");
printf("\n1. Divide");

scanf("%d", &choice);

printf("\nNow enter two numbers");

scanf("%f", &a);
scanf("%f", &b);

if (choice == 1)
{
result = a + b;
printf("%f", result);
} else if (choice == 2)
{
result = a - b;
printf("%f", result);
} else if (choice == 3)
{
result = a * b;
printf("%f", result);
} else if (choice == 4)
{
result = a / b;
printf("%f", result);
} else
{
printf("Wrong Choice");
}
return 0;
}

Try the code by clicking here.

So run this programme in ur emulator or here and write ur reviews in the comment box
Thank You

Monday, 19 December 2016

Basic of web designing

WEBSITE / WEB Application

So, Today I am gonna teach you the basic overview of a website.
As everything consists of what seems to us, and the part which does not appears
to the user.
So basically the part which seems to us is known as Front End or the user interface,
and the other one is known as back end which generally does not appear.
So like in a building a foundation plays an important role likewise the backend of a web application plays an important role
in dynamic web pages.

1. Front End

In common language it is the user interface or a plateform with which a user interacts with the web page.
It is made with the help of HTML, CSS, JavaScript.

Generally a good looking web application I mean the user interface of the web pages can be created with the
CSS only but to add more functions in the page like on click effects (Like a pop-up appears when we click a button)
we generally use JavaScript.

Note: JavaScript is a language which can be used both in client side as well as in server side scripting also.

2. BACK End

It is the most important part of any web page or a web application.
It interacts with the server of more precisely with tha database.
Many languages are available for server side scripting like,

  1. php
  2. python
  3. .NOT (pronounced as Dot Net) etc.

Many programmers use the as per the convenience of the programmer of the need of the web application.
And the most common is php (hypertext pre processor) language. So a web page can be made or more precisely a dynamic web page is
the combination of the front end and the back end.

Something to read

Now a days we use MVC concept in designing any web application.
Let us know what is MVC
M => Model
V => View
C => Control
So here model stands for the database related statements like performing database queries
like fetching data, inserting data, updating data, deleting data.
View stands for the part which a user is able to see or it is the front end of the application.
Controller as the name specifies it is the controller of what is being taken and what is being viewed.

For example look at the web address.
www.example.com/notice/create

So here don't think that notice is a directory as new programmers think
obviously it is common I too thought the same until I learned this concept.
So here notice calls a controller named notice and the create is a function of it.
If you are not getting it leave it now I will describe it after we finish our front-end tutorials.
Thank You for reading this.

Sunday, 18 December 2016

I am BACK

Sorry guys I could not complete my promise for last few months/YEARS.

Ya but now I am available with more knowledge of web designing.

So now I will talk about basics of web designing.

Basic elements of a web page

Every web page consist of two parts
  1. Front end
  2. Back end

Front End

It is made with the help of HTML JS and CSS. It consists of the web part which we see in the screen.
Or it may be said that it is UI i.e. user interface of the page.

Back End

It is made with the help of languages such as php, again js, .net. It contains the part which interacts with the database.

Thank You, I will post some new things soon.