Tuesday 8 November 2016

How .net program is executed by differently from other languages?




Why the assembly is used?


If we want to execute c++ or vb programs first we compile the program. Result is an assembly file. Extension of file depend upon the type of program. it may be .dll or exe. Actually why should we use assembly?. Because our operating system can not understand high level languages. we have to converted in to machine code  which is only 0 or 1.that is what assembly contains

What happens in case .of java?


In java files are not compiled into machine code. That is converted into class files. It will not be in  human readable form. it is because java is platform independent .The JVM(java virtual machine) responsible for execution is different for every platform. So JVM interpret class files of java and run it.

What is the Usage of CLR?


   In .net we can run c#, vb.net, c++,  j# ext. like JVM in java there is CLR (Common Language runtime)which manages the program running. Also it takes care for memory management. For example when we create object for a class. In language like c++ it allocates memory. But even after finishing the execution of program the memory is not freed. we have to manually write destructors for freeing memory. But in case of .NET there is a garbage collector which runs when we run the program it frees the memory by objects not in use. Even garbage collector can be manually called. But it is not a good programming practice.

Before entering in CLR the program(written in languages like c#,vb.net,c++ or,j#) are first compiled in to assembly but is not any machine code or class files. It is intermediate language that assembly contains. somebody calls itself as MSIL(Microsoft intermediate language. Others calls it as  CIL(common intermediate language. During the execution of program MSIL enters into CLR which contains JIT(Just IN time Compiler). It translates assembly code in to native machine code .and then executes the program.

What is the extension of Assembly file?


Assembly file extension may be .dll or .exe. For example when we build windows application .exe file get generated. But in case of class library or web application .dll file get generated. Main advantage of using CLR is it is portable.  Machine code generated by JIT compiler depends upon which underlying OS(operating system) it is going to run. And MSIL is also called Managed code. CLR managing code of the assembly code so it is called managed code.

What happens to code generated by CLR after stopping the execution of program?


And after stopping the execution of a program the code generated by CLR get deleted. While all other languages are managed code ,the code of c++ is available as both Managed and unmanaged code. the reason is c++ programs have to be backward compatibility for projects already created before inventing .NET.I think you would know about visual c++ language one of the component  of visual studio 6.0.







what is .NET?



what is .NET?

.NET is a software development platform created by Microsoft.you can write programs in any language and run it in  visual studio.Net. it is just opposite to what oracle company's java said.actually you can write a program in java compile it or run it in any platform. microsoft's intention for developing .net is to catch the market of java.
What are the two parts of .NET frameworks consists of?
  1. frame work class library(FCL)
  2. common language run time.(CLR)
What is FCL?

FCL  is a collection of ready made classes that can be used for commonly needed programming tasks.
It is used while creating software in area of
  1. Graphics
  2. Multimedia
  3. Net working
  4. Internet
  5. Mobile computing
  6. Web applications

what is CLR?

CLR is responsible for  execution of programs. It is responsible for handling memory and provides security while executing a program.

Do you know about MSIL?

You first have to know about .NET  is not limited one we can run programs written in different languages.
How can a compiler can know about commands written in different languages. Any program which ever language it has been written it can be converted in intermediate language called as Microsoft intermediate language(MSIL). After that MSIL is compiled into machine language.

What is  language interoperability?

why should we convert c# or vb programs into MSIL instead of directly compile in to machine language.
good question ?
here the language interoperability come.This means that different parts  of same software can be written in any .NET compliant languages (like c#,vb.net,vc++.) even after that   we can compile the software in to common executable programs

--------will continue





Friday 30 September 2016

Elements of programming-4




If statement.
It is a conditional statement. It conditionally executing a branch of statements .There are different types of if statement.
1.       simple if
2.       if-else
3.       if-else if-else
4.       switch statement.
Simple If statement:
A relational expression is checked. If the condition is true a block of coding will be executed.if  it returns false the block of coding will not get executed.


For example take the following c program
.
#include<stdio.h>
#include<conio.h>
void main()
{
int mark;
Clrscr();
printf(“enter your score”);
scanf(“%d”,&mark);
printf(“your score is %d”,mark);
if(mark>=90)
{
printf(“excellent”);
}
getch();
}
Program explanation:

The above program asks the score as input. It prints your  mark.if your mark>=90 then it additionally prints the output excellent.

If—else
In this case a relational expression is tested .if the result is true then a block of coding will be executed.if it returns false another block of coding will be executed.

#include<stdio.h>
#include<conio.h>
void main()
{
int mark;
Clrscr();
printf(“enter your score”);
scanf(“%d”,&mark);
printf(“your score is %d”,mark);
if(mark>=40)
{
printf(“pass”);
}
Else
{
Printf(“fail”);
}
getch();
}

Program explanation:
In the above c program mark is input. If it is greater than or equal  to 40 result is printed as false.
If the mark<40 else part will be executed  and printed as fail


                                                --------to be continued
                                                                muthu karthikeyan madurai

Thursday 29 September 2016

Elements of programming ----3



                             Muthu karthikeyan, Madurai

Operators:

 

Types of operator:


Arithmetic operator
Short hand assignment operator
Increment /decrement operator
Relational operators
Logic operator
Ternary operator

Arithmetic operator:

+, -, *, /, %
Plus, minus, multiplication, division         
First three are same as mathmetical  operations.
Fourth division operation is different. i.e if we divide a int by another int result is integer only
For example
13/5=2 is the result. Decimal portions were removed
If at least any one is float or double the result is float
For example:
13.0/5=2.6
13/5.0=2.6
13.0/5.0=2.6
o.k then what about % operator? do you think that it is percentage calculating operator?
No
It is called as modulus operator.
That is one integer is divided by another integer .it returns remainder value
Example : 13/5=3.
In c , c++   modulus  operations are performed on Integer type only. In advanced languages like java, c sharp,vb.net modulus operator is also can be used also on float and double.

Short hand Assignment operator:


a=a+5 can be also written as a+=5
a=a-5 can be also written as a-=5
It totally applied for all 5 types of arithmetic operator.
Increment/decrement operator:
++,--
a=10;
a++;
now a value will be eleven because ++ operator increases the value by one
also ++a will increment the values by one.
Next:
--
It is called as decrement operator.
a=10;
a--;
now q value be only nine. because decrement operator wil decrement by . one
and  --a  may also decrement the value by one.
But in order of execution ++a(pre increment operator )has order of process high in a mathematical expression is high. but a++ (post decrement operator).has low precedence. It also applies to decrement operator.

Relational operator:


It is used for comparing one value with other value. it returns only true or false value
<  less  than
<=less  than or equal to
> greater than
>=greater than or equal to
==equals to(note there are two = symbols
!=not equal to
Examples:
a=10;
b=5;
c=15;
d=10;
a>b   ----true
a>c-----false
a==d—true
a!=d---false
logical operators:
compare two or more relational expression. It also returns true or false value
&&,||,!
&&---(and) both side of relational expression must be true.
||-(or)at least one side of expression must be true.
!-it inverts the results (if the result is true  then the result is false and vice-versa
Examples:
(a>b)&&(a>c)
(a>b)||(a>c)
!(a>b)

Ternary operator:

Make a relational expression execution . if the expression returns true a value will be returned , if the result is false b value will be returned.

Syntax:

(a>b)?a : b;
a=10;b=5;
big=(a>b)?a:b;
First the comparison(a>b) returns true so a value(i.e 10) will be returned to big.

 contact:  91 96293 29142

















Wednesday 6 July 2016

Elements of programming-2



constants:
constants are also memory locations like variables but their values that can not be changed through out the program. only initial assignment is considered. most of the programming languages use const keyword to define constant.
Example:
const float PI=3.14;
some language also # define keyword to define a constant
Datatypes:
when we declare a variable at first time we should tell the compiler what type of data we are going to store.
it may be integer, floating point numbers or char. advanced language also have string type. following are thre primarydata types:
int
float
double
char:

int:
int means integer which indirectly means whole numbers. usually c,c++ int data type takes 2 bytes of memory. but modern c,c++ and alsoc#,java ,vb.net take 4 bytes of memory. modified long int data type take 8 bytes of memory in all modern languages.
float & double:
both are used to store floating point numbers.float data types takes only 4 bytes. double data type takes 8 bytes memory.if you want accuracy you are recommended to choose double data type.
char:
it takes 2 bytes of memory in java & c# because it follows unicode method to store data. it can store only one character .some basic languages uses array of characters to store more than one character.char data type is actually treated internally as char data type.
String:
modern languages like java and c# uses string data type to store more than one character. while char type data are put in to single quotes, string datas are put into double quotes

                                              To  be continued (muthu karthikeyan, madurai)