Apr 29, 2013

What is .NET Framework Class Library ?

The .NET Framework class library is a collection of reusable types that tightly integrate with the common language runtime. The class library is object oriented, providing types from which your own managed code can derive functionality. This not only makes the .NET Framework types easy to use, but also reduces the time associated with learning new
features of the .NET Framework. In addition, third-party components can integrate seamlessly with classes in the .NET Framework.
For example, the .NET Framework collection classes implement a set of interfaces that you can use to develop your own collection classes. Your collection classes will blend seamlessly with the classes in the .NET Framework.
As you would expect from an object-oriented class library, the .NET Framework types enable you to accomplish a range of common programming tasks, including tasks such as string management, data collection, database connectivity, and file access. In addition to these common tasks, the class library includes types that support a variety of specialized development scenarios. For example, you can use the .NET Framework to develop the following types of applications and services:
  • Console applications.
  • Scripted or hosted applications.
  • Windows GUI applications (Windows Forms).
  • ASP.NET applications.
  • XML Web services.
  • Windows services.
For example, the Windows Forms classes are a comprehensive set of reusable types that vastly simplify Windows GUI development. If you write an ASP.NET Web Form application, you can use the Web Forms classes.



Apr 28, 2013

What is Common Language Runtime in .net ?

The common language runtime manages memory, thread execution, code execution, code safety verification, compilation, and other system services. These features are intrinsic to the managed code that runs on the common language runtime.
With regards to security, managed components are awarded varying degrees of trust, depending on a number of factors that include their origin (such as the Internet, enterprise network, or local computer). This means that a managed component might or might not be able to perform file-access operations, registry-access operations, or other sensitive functions, even if it is being used in the same active application.
The runtime enforces code access security. For example, users can trust that an executable embedded in a Web page can play an animation on screen or sing a song, but cannot access their personal data, file system, or network. The security features of the runtime thus enable legitimate Internet-deployed software to be exceptionally feature rich.
The runtime also enforces code robustness by implementing a strict type- and code-verification infrastructure called the common type system (CTS). The CTS ensures that all managed code is self-describing. The various Microsoft and third-party language compilers
Generate managed code that conforms to the CTS. This means that managed code can consume other managed types and instances, while strictly enforcing type fidelity and type safety.
In addition, the managed environment of the runtime eliminates many common software issues. For example, the runtime automatically handles object layout and manages references to objects, releasing them when they are no longer being used. This automatic memory management resolves the two most common application errors, memory leaks and invalid memory references.
The runtime also accelerates developer productivity. For example, programmers can write applications in their development language of choice, yet take full advantage of the runtime, the class library, and components written in other languages by other developers. Any compiler vendor who chooses to target the runtime can do so. Language compilers that target the .NET Framework make the features of the .NET Framework available to existing code written in that language, greatly easing the migration process for existing applications.
While the runtime is designed for the software of the future, it also supports software of today and yesterday. Interoperability between managed and unmanaged code enables developers to continue to use necessary COM components and DLLs.
The runtime is designed to enhance performance. Although the common language runtime provides many standard runtime services, managed code is never interpreted. A feature called just-in-time (JIT) compiling enables all managed code to run in the native machine language of the system on which it is executing. Meanwhile, the memory manager removes the possibilities of fragmented memory and increases memory locality-of-reference to further increase performance.
Finally, the runtime can be hosted by high-performance, server-side applications, such as Microsoft® SQL Server™ and Internet Information Services (IIS). This infrastructure enables you to use managed code to write your business logic, while still enjoying the superior performance of the industry's best enterprise servers that support runtime hosting.








Apr 26, 2013

What is Microsoft.NET Framework ?

The .NET Framework is a computing platform that simplifies application development in the highly distributed environment of the Internet. The .NET Framework is designed to fulfill the following objectives:
  • To provide a consistent object-oriented programming environment whether object code is stored and executed locally, executed locally but Internet-distributed, or executed remotely.
  • To provide a code-execution environment that minimizes software deployment and versioning conflicts.
  • To provide a code-execution environment that guarantees safe execution of code, including code created by an unknown or semi-trusted third party.
  • To provide a code-execution environment that eliminates the performance problems of scripted or interpreted environments.
  • To make the developer experience consistent across widely varying types of applications, such as Windows-based applications and Web-based applications.
  • To build all communication on industry standards to ensure that code based on the .NET Framework can integrate with any other code.
    Overview of .net framework


  • The .NET Framework has two main components: the common language runtime and the .NET Framework class library. The common language runtime is the foundation of the .NET Framework. You can think of the runtime as an agent that manages code at execution time, providing core services such as memory management, thread management, and remoting, while also enforcing strict type safety and other forms of code accuracy that ensure security and robustness. In fact, the concept of code management is a fundamental principle of the runtime. Code that targets the runtime is known as managed code, while code that does not target the runtime is known as unmanaged code. The class library, the other main component of the .NET Framework, is a comprehensive, object-oriented collection of reusable types that you can use to develop applications ranging from traditional command-line or graphical user interface (GUI) applications to applications based on the latest innovations provided by ASP.NET, such as Web Forms and XML Web services.


    The .NET Framework can be hosted by unmanaged components that load the common language runtime into their processes and initiate the execution of managed code, thereby creating a software environment that can exploit both managed and unmanaged features. The .NET Framework not only provides several runtime hosts, but also supports the development of third-party runtime hosts.


    For example, ASP.NET hosts the runtime to provide a scalable, server-side environment for managed code. ASP.NET works directly with the runtime to enable Web Forms applications and XML Web services, both of which are discussed later in this topic.
    Internet Explorer is an example of an unmanaged application that hosts the runtime (in the form of a MIME type extension). Using Internet Explorer to host the runtime enables you to embed managed components or Windows Forms controls in HTML documents. Hosting the runtime in this way makes managed mobile code (similar to Microsoft® ActiveX® controls) possible, but with significant improvements that only managed code can offer, such as semi-trusted execution and secure isolated file storage.


Apr 24, 2013

C program to read a file and display its contents along with line numbers before each line.


#include<stdio.h>
void main()
{
FILE *fp;
char ch;
char source[67];
int count = 1;
clrscr();
puts("enter the file name:");
gets(source);
fp=fopen(source,"r");// read only mode for the source file
if(fp==NULL)
{
puts("unable to open the file:");
getch();
exit();
}
clrscr();
printf("file name:%s",source);
printf("\n line:-%d\t",count);
while((ch=getc(fp))!=EOF)
{
if(ch=='\n')
{
count++;
printf("\nline:-%d\t",count);
}
else
{
printf("%c",ch);
}
}
printf("\n press any key...");
getch();
fclose(fp);
}

Apr 23, 2013

C++ program to find LCM and HCF of given 3 numbers

#include<iostream.h>
#include<conio.h>
void lcm(int, int, int);
void hcf(int, int, int);
void main()
{
char choice;
do
{ int a,b,c;
clrscr();
cin>>a>>b>>c;
lcm(a,b,c);
hcf(a,b,c);
cout<<"\n\nDO YOU WANT TO REPEATTHE PROGRAM?(Y/N): ";
cin>>choice;
}while(choice=='Y'||choice=='y');
}
void lcm(int x,int y, int z)
{
long max,lcom, count, flag=0;
if(x>=y&&x>=z)
max=x;
else if(y>=x&&y>=z)
max=y;
else if(z>=x&&z>=y)
max=z;
for(count=1;flag==0;count++)
{
lcom=max*count;
if(lcom%x==0 && lcom%y==0 && lcom%z==0)
{
flag=1;
cout<<"\nTHE LCM OF "<<x<<","<<y<<","<<z<<" IS "<<lcom;
}
}
}
void hcf(int p, int q, int r)
{
int gcf=1,flag=0, count;
for(count=1; flag==0;count++)
{
if(p%count==0&&q%count==0&&r%count==0)
gcf=count;
if(count>p&&count>q&&count>r)
{
flag=1;
cout<<"\nTHE GCF OF "<<p<<","<<q<<","<<r<<" IS "<<gcf;
}
}
}

C program to find the reverse of a given number


#include<stdio.h>
#include<conio.h>
void main()
{
int no,d,sc,rev=0;
clrscr();
printf("\nenter no(find for reverse)=");
scanf("%d",&no);
sc=no; //second copy of no
while(no>0)
{
d=no%10;
rev=rev*10+d;
no=no/10;
}
printf("\n \n %d is rev",rev);
getch();
}

OUTPUT


enter no(find for reverse)=123
321 is rev



Apr 22, 2013

Some of the terms programmers frequently use. Part Two

Message

An object in isolation is of no use. Its value comes from its interactions with other objects.
This interaction takes place through messages. A message consists of three parts
(i)   A receiver object
(ii)   A method the receiver knows how to execute
(iii)   Parameters, if any.

Cohesion


Cohesion is a measure of how much an item, say for e.g. a class or method, makes sense. Objects with low cohesion are more likely to be changed. A method is highly cohesive if it does one thing and only one thing.  High cohesion is desirable.

Coupling


Object coupling describes the degree of inter relationships among the objects that make up a system. The more any one object knows about any other object in the system, the tighter the coupling is between those objects. In other words, coupling is a measure of how two items, such as classes or methods, are interrelated. When one class depends on another class they are said to be coupled. When one class interacts with another class, but does not have any knowledge of the implementation details of the other class they are said to be loosely coupled. When one class relies on the implementation of another class, they are said to be tightly coupled.  Always try for loose coupling among objects.

Abstract classes and Interfaces


 

Abstract Class


Abstract are classes that cannot be instantiated, and are frequently either partially
implement end, or not at all implemented. Abstract classes are useful when creating
components because they allow you specify an invariant level of functionality in some methods, but leave the implementation of other methods until a specific implementation of that class is needed. When implementing an abstract class, you must implement each abstract method in that class, and each implemented method must receive the same number and type of arguments, and have the same return value, as the method specified in the abstract class. Classes can inherit from only one abstract class.

Interface


An interface is a reference type and it contains only  abstract members . We cannot have any implementation code in the interface. The interface contains only declaration for its members.  Interface’s members can be events, methods, properties and indexers. An interface is also known as a “contract”.  The entire client which uses the interface must fulfil the contract by implementing the interface. A class can implement multiple interfaces.

How to decide between Abstract class and Interface


If you want to provide common, implemented functionality among all implementations of your component, use an abstract class. Abstract classes allow you to partially implement your class, whereas interfaces contain no implementation  for any members.


If the functionality you are creating will be useful across a wide range of disparate objects, use an interface. Abstract classes should be used primarily for objects that are closely related, whereas interfaces are best suited for providing common functionality to unrelated classes.

C program to find a given number is pallindrome or not


#include<stdio.h>
#include<conio.h>
void main()
{
int no,d,sc,rev=0;
clrscr();
printf("\nenter no(chek for pallinrome)=");
scanf("%d",&no);
sc=no; //second copy of no
while(no>0)
{
d=no%10;
rev=rev*10+d;
no=no/10;
}
if(rev==sc)
{
printf("\n \n %d is pallindrome",sc);
}
else
{
printf("\n \n%d is not pallindrome",sc);
}
getch();
}

OUTPUT


enter no(chek for pallinrome)=121
121 is palindrome
enter no(chek for pallinrome)=132
132 is not pallindrome


Apr 20, 2013

C program to enter two matrix and print its multiplication


#include<stdio.h>
#include<conio.h>
void main()
{
int a[10][10],b[10][10],c[10][10]={0},i,j,k,m,n,p,q;
clrscr();
printf("enter rows of matrix a=");
scanf("%d",&m);
printf("enter columns of matrix a=");
scanf("%d",&n);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("a[%d][%d]=",i,j);
scanf("%d",&a[i][j]);
}
}
printf("\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%3d",a[i][j]);
}
printf("\n");
}
printf("\n\n enter rows of matrix b=");
scanf("%d",&p);
printf("enter columns of matrix b=");
scanf("%d",&q);
for(i=0;i<p;i++)
{
for(j=0;j<q;j++)
{
printf("b[%d][%d]=",i,j);
scanf("%d",&b[i][j]);
}
}
for(i=0;i<p;i++)
{
for(j=0;j<q;j++)
{
printf("%3d",b[i][j]);
}
printf("\n");
}
printf("\n\n");
for(i=0;i<m;i++)
{
for(j=0;j<q;j++)
{
for(k=0;k<p;k++)
{
c[i][j]+=a[i][k]*b[k][j];
}
}
}
printf("multiplication is\n\n");
for(i=0;i<m;i++)
{
for(j=0;j<q;j++)
{
printf("%5d",c[i][j]);
}
printf("\n");
}
getch();
}

OUTPUT


enter rows of matrix a=2
enter columns of matrix a=3
a[0][0]=1
a[0][1]=2
a[0][2]=3
a[1][0]=4
a[1][1]=5
a[1][2]=6
1 2 3
4 5 6
enter rows of matrix b=3
enter columns of matrix b=2
b[0][0]=4
b[0][1]=2
b[1][0]=5
b[1][1]=3
b[2][0]=1
b[2][1]=6
4 2
5 3
1 6
multiplication is
17 26
47 59


Apr 19, 2013

C program to find maximum number from array of ten numbers


#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],max=0,i;
clrscr();
for(i=0;i<=9;i++)
{
printf("enter the number:");
scanf("%d",&a[i]);
}
for(i=0;i<=9;i++)
{
printf("a[%d]=%d\n",i,a[i]);
if(max<a[i])
{
max=a[i];
}
}
printf("the maximum is %d",max);
getch();
}

OUTPUT


enter the number:21
enter the number:45
enter the number:26
enter the number:35
enter the number:44
enter the number:66
enter the number:58
enter the number:12
enter the number:32
enter the number:52
a[0]=21
a[1]=45
a[2]=26
a[3]=35
a[4]=44
a[5]=66
a[6]=58
a[7]=12
a[8]=32
a[9]=52
the maximum is 66



Apr 18, 2013

C program to find gcd(hcf) and lcm of any two numbers using function


#include<stdio.h>
#include<conio.h>
void gcd(int,int);
void main()
{
int n1,n2;
clrscr();
puts("enter no1 ==>");
scanf("%d",&n1);
puts("enter no2 ==>");
scanf("%d",&n2);
gcd(n1,n2);
getch();
}
void gcd(int n1,int n2)
{ int product,temp,lcm;
product=n1*n2;
while(n1>0)
{
if(n1<n2)
{
temp=n1;
n1=n2;
n2=temp;
}
n1=n1%n2;
}
printf("gcd=%d",n2);/*greatest common diviser(gcd)/(hcf)*/
lcm=product/n2;
printf("\nlcm=%d",lcm);
}

OUTPUT


enter no1 ==>
12
enter no2 ==>
18
gcd=6
lcm=36



Apr 17, 2013

C program to count odd numbers from entered numbers


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,no,n,o=0;
clrscr();
printf("how many nos.you want to enter =");
scanf("%d",&no);
for(i=1;i<=no;i++)
{
printf("no[%d]=",i);
scanf("%d",&n);
if(n%2!=0)
{
o++;
}
}
printf("odd=%d",o);
getch();
}


OUTPUT


how many nos.you want to enter =5
no[1]=1
no[2]=2
no[3]=5
no[4]=6
no[5]=7
odd=3


Apr 16, 2013

C program to sort numbers using bubble sort


#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i,j,temp=0;
clrscr();
for(i=0;i<=4;i++)
{
printf("enter (%d) no=",i+1);
scanf("%d",&a[i]);
}
for(i=0;i<=4;i++)
{
for(j=i+1;j<=4;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
for(i=0;i<=4;i++)
{
printf("%d\n",a[i]);
}
getch();
}

OUTPUT


enter (1) no=9
enter (2) no=5 
enter (3) no=42 
enter (4) no=6 
enter (5) no=2 




42





why spinlocks are not appropriate for single-processor systems yet are often used in multiprocessor systems ?

ANSWER:


Spinlocks are not appropriate for single-processor systems
because the condition that would break a process out of the spinlock
could be obtained only by executing a different process. If the process is
not relinquishing the processor, other processes do not get the opportunity to set the program condition required for the first process to make
progress. In a multiprocessor system, other processes execute on other
processors and thereby modify the program state in order to release the
first process from the spinlock.


why interrupts are not appropriate for implementing synchronization primitives in multiprocessor systems.


ANSWER:


Interrupts are not sufficient in multiprocessor systems since
disabling interrupts only prevents other processes from executing on the
processor in which interrupts were disabled; there are no limitations on
what processes could be executing on other processors and therefore the
process disabling interrupts cannot guarantee mutually exclusive access
to program state.


Apr 15, 2013

Defination of the essential properties of operating systems


Define the essential properties of the following types of operating sys-tems:
a. Batch
b. Interactive
c. Time sharing
d. Real time
e. Network
f. Parallel
g. Distributed
h. Clustered
i. Handheld

ANSWERS:


a. Batch processing:- Jobs with similar needs are batched together and run through the computer as a group by an operator or automatic job sequencer. Performance is increased by attempting to keep CPU and I/O devices busy at all times through buffering, off-line operation, spooling, and multi-programming. Batch is good for executing large jobs that need little interaction; it can be submitted and picked up later.


b. Interactive System:- This system is composed of many short transactions where the results of the next transaction may be unpredictable.
Response time needs to be short (seconds) since the user submits and waits for the result.

c. Time sharing:- This systems uses CPU scheduling and multipro-gramming to provide economical interactive use of a system. The CPU switches rapidly from one user to another. Instead of having
a job defined by spooled card images, each program reads its next control card from the terminal, and output is normally printed immediately to the screen.



d. Real time operating system:- Often used in a dedicated application, this system reads information from sensors and must respond within a fixed amount of time to ensure correct performance.


e. Network:- Provides operating system features across a network such as file sharing.

f. SMP (Symmetric multiprocessing):- Used in systems where there are multiple CPU’s each running the same copy of the operating system.Communication takes place across the system bus.


g. Distributed systems:- This system distributes computation among several physical processors. The processors do not share memory or a clock. Instead, each processor has its own local memory. They
communicate with each other through various communication lines, such as a high-speed bus or local area network.


h. Clustered system:-  A clustered system combines multiple computers into a single system to perform computational task distributed across the cluster.


i. Handheld System:- A small computer system that performs simple tasks such as calendars, email, and web browsing. Handheld systems differ from traditional desktop systems with smaller memory and
display screens and slower processors.



If you need any more definitions regarding computer systems. Fell free to comment



C program to find the size of a text file without traversing it character by character


#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main()
{
struct entry
{
char fname[8];
char ext[3];
char unusual[17];
long int size;
};
struct entry e[16];
int i,j,c;
char yname[8];
char ch=1,len,len1;
clrscr();
absread(0,1,5,e);
for(i=0;i<16;i++)
printf("%s %s %d\n",e[i].fname,e[i].ext,e[i].size);
printf("enter the filename whose size is to be found");
scanf("%s",&yname);
len1=len=strlen(yname);
i=0;
while(i<16)
{
while(len--!=0)
{
if(e[i].fname[len]==yname[len])
ch=0;
else
{
ch=1;
break;
}
}
if(ch==0&&len==-1)
break;
len=len1;
i++;
}
if(ch==0)
{
printf("%s",e[i].fname);
printf("\t%ld bytes",e[i].size);
}
else
printf("h");
getch();
}

Some of the terms programmers frequently use. Part one


Classes and Objects
The class represents or defines the common characteristics/attributes of an object of a particular type. For e.g. you might want to define a class of “ Person”. Every person will share some common characteristics/attributes like first name, last name, address etc.. So, a class serves as a blueprint for similar type of object. A class is made up of attributes and behavior. Attributes are defined in terms of member variables and behavior is expressed in terms of function.
An object is an instance of a class. It is a representation of a real world thing. Object can have both attributes/data and behaviors. For e.g. You, me are instance of t he “Person” class. We share some common attributes like we both have a first name, a last name and so on. We have some common behaviors like walking, talking etc.

Abstraction
Abstraction refers to the act of representing essential features without unnecessarily
including the background details or information i.e. representing a complex problem in simple terms. Classes provides a mechanism to abstract the required attributes such as first name, last name in case of “Person” class and functions to operate on these attributes. Classes are also known as “Abstract Data Type or ADT”.

Encapsulation(or Information Hiding)
Encapsulation is a technique where data and its associated behaviors(function) are wrapped in a single unit (Class). The data is hidden fro m the outside word. The purpose is to reveal as little as possible about the inner workings of the class. The only way to access these data is through public interfaces provided by the functions.

Inheritance
Inheritance is a technique with which an object of one class acquires attributes and
behaviors from an object of another class. This is one way to achieve reusability in OOP.
Inheritance models “is -a” relationship . For e.g. a “car” is an automobile. In this case
the “automobile” is called the base class and “car” is called as derived class or inherited class.  This type of reuse is often called  white- box reuse. This term refers to the fact that with inheritance, the parent class implementation is often visible to the subclasses.

Composition
When reuse is achieved by composing another object, the technique is known as
composition.  Composition models “has-a” relationship .  This approach requires that the objects have well - defined interfaces since the internals of the objects are unknown. Because objects are treated only as "black boxes," this type of reuse is often called  black-box  reuse.

Polymorphism
The ability of different objects to respond to the same message in different ways is called polymorphism.  Polymorphism is also the ability of an object to take more than one forms, for e.g. an operation may exhibit different behavior in different instances. The behavior depends upon the types of data used in the operation. There are basically two types of polymorphism
 static and dynamic polymorphism. Method overloading is an example
of static polymorphism whereas overriding would be an example of dynamic
polymorphism.

The differences among short-term, medium-term, and long-term scheduling


What are the differences among short-term, medium-term, and long-term scheduling

Answer:

Short-term(CPU scheduler)—selects from jobs in memory those
jobs that are ready to execute and allocates the CPU to them.

Medium-term—used especially with time-sharing systems as an
intermediate scheduling level. A swapping scheme is implemented
to remove partially run programs from memory and reinstate them
later to continue where they left off.

Long-term(job scheduler)—determines which jobs are brought into memory for processing.
The primary difference is in the frequency of their execution. The short-term must select a new process quite often. Long-term is used much less often since it handles placing jobs in the system and may wait a while for a job to finish before it admits another one.


Give two reasons why caches are useful. What problems do they solve? What problems do they cause?


QUESTION:
Give two reasons why caches are useful. What problems do they solve?
What problems do they cause? If a cache can be made as large as the
device for which it is caching (for instance, a cache as large as a disk),
why not make it that large and eliminate the device?.

ANSWER: 


Caches are useful when two or more components need to ex-change data, and the components perform transfers at differing speeds. Caches solve the transfer problem by providing a buffer of intermediate speed between the components. If the fast device finds the data it needs in the cache, it need not wait for the slower device. The data in the cache must be kept consistent with the data in the components. If a component has a data value change, and the datum is also in the cache, the cache must also be updated. This is especially a problem on multiprocessor systems where more than one process may be accessing a datum.
A component may be eliminated by an equal-sized cache, but only if:
 (a) the cache and the component have equivalent state-saving capacity (that is, if the component retains its data when electricity is removed, the cache must retain data as well),
 and
 (b) the cache is affordable, because faster storage tends to be more expensive.


QUESTION:
How the problem of maintaining coherence of
cached data manifests itself in the following processing environments:
a. Single-processor systems
b. Multiprocessor systems
c. Distributed systems

ANSWER:
In single-processor systems, the memory needs to be updated when a processor issues updates to cached values. These updates can be performed immediately or in a lazy manner. In a multiprocessor system, different processors might be caching the same memory location in its local caches. When updates are made, the other cached locations need to be invalidated or updated. In distributed systems, consistency of cached memory values is not an issue. However, consistency problems might arise when a client caches file data.