Tuesday, 8 January 2013

RETURNING MULTIPLE VALUE IN FUNCTION THROUGH POINTERS
void func(int *px,int *py); //prototype

void main(void)
{
int x,y;

func(&x,&y);
printf("x=%d y=%d",x,y);
}

void func(int *px,*py)
{
*px=6;
*py=7;
}




OUTPUT:
x=6 y=7
-----xx------------------------x----------------------x-------------------x-------------





#include<iostream.h>
#include<conio.h>
int op(int x,int y,int &l,int & m)
{
int c;
c=x+y;
l=x-y;
m=x*y;
return c;
}
void main()
{
int a,b,*p,*q;
cin>>a>>b;
cout<<" "<<op(a,b,*p,*q);
cout<<*p;
cout<<*q;
getch();
}

C language games


INTERESTING PROGRAMS IN C LANGUAGE








Beeps the speaker

#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
int menu(void);


main()
{
while(1)
{
/*get selection and execute the relevant statement*/
switch(menu())
{
case 1:
{
puts("sound the speaker 1\n");
sound(2000);
sleep(2);
nosound();
break;
}
case 2:
{
puts("sound that speaker 2\n");
sound(4000);
sleep(2);
nosound();
break;
}
case 3:
{
puts("You are quitting\n");
exit(0);
break;
}
default:
{
puts("Invalid menu choice\n");
break;
}
}
}
return 0;
}

/*menu function*/
int menu(void)
{
int reply;
/*display menu options*/
puts("Enter 1 for beep 1.\n");
puts("Enter 2 for beep 2.\n");
puts("Enter 3 to quit.\n");
/*scan for user entry*/
scanf("%d", &reply);

return reply;
}
--------------x---------------------x---------------------x------------------------x-------------------

HANG MAN

#include <stdio.h>

int main()
{

 int mybday = 20;            //declare variable to be guessed
 int guess;              //declare variable to store guessed date
 int max = 31;              //declare variable to test for invalid input
 int min = 1;              //declare variable to test for invalid input

 printf("Try to guess the day of my Birthday: ");    //display the intro and
directions
 scanf("%d",&guess);            //`get the users guess and store it in the
variable guess

 if (guess == mybday)
 {
   printf("You Win!!");          //print you win if guess is correct
 }
 else if (guess < min)
 {
   printf("Thats NOT A DATE!!");        //print `Error for invalid input
 }
 else if (guess > max)
 {
   printf("There isn't %d days in a month!",guess);  //print Error for
invalid input
 }
 else if (guess > mybday)
 {
   printf("Too High!");          //print too high if guess is above answer
 }
 else if (guess < mybday)
 {
   printf("Too Low!");          //print too low if guess is below answer
 }
 else
 {
   printf("Try again!!");          //Print try again if guess if all else is not
true (not possible)
 }

 return 0;
}

The History of the C Language

The C programming language was devised in the early 1970s by Dennis M. Ritchie an employee from Bell Labs (AT&T).
In the 1960s Ritchie worked, with several other employees of Bell Labs (AT&T), on a project called Multics. The goal of the project was to develop an operating system for a large computer that could be used by a thousand users. In 1969 AT&T (Bell Labs) withdrew from the project, because the project could not produce an economically useful system. So the employees of Bell Labs (AT&T) had to search for another project to work on (mainly Dennis M. Ritchie and Ken Thompson).
Ken Thompson began to work on the development of a new file system. He wrote, a version of the new file system for the DEC PDP-7, in assembler. (The new file system was also used for the game Space Travel). Soon they began to make improvements and add expansions. (They used there knowledge from the Multics project to add improvements). After a while a complete system was born. Brian W. Kernighan called the system UNIX, a sarcastic reference to Multics. The whole system was still written in assembly code.
Besides assembler and Fortran, UNIX also had an interpreter for the programming language B. ( The B language is derived directly from Martin Richards BCPL). The language B was developed in 1969-70 by Ken Thompson. In the early days computer code was written in assembly code. To perform a specific task, you had to write many pages of code. A high-level language like B made it possible to write the same task in just a few lines of code. The language B was used for further development of the UNIX system. Because of the high-level of the B language, code could be produced much faster, then in assembly.
A drawback of the B language was that it did not know data-types. (Everything was expressed in machine words). Another functionality that the B language did not provide was the use of “structures”. The lag of these things formed the reason for Dennis M. Ritchie to develop the programming language C. So in 1971-73 Dennis M. Ritchie turned the B language into the C language, keeping most of the language B syntax while adding data-types and many other changes. The C language had a powerful mix of high-level functionality and the detailed features required to program an operating system. Therefore many of the UNIX components were eventually rewritten in C (the Unix kernel itself was rewritten in 1973 on a DEC PDP-11).
The programming language C was written down, by Kernighan and Ritchie, in a now classic book called “The C Programming Language, 1st edition”. (Kernighan has said that he had no part in the design of the C language: “It’s entirely Dennis Ritchie’s work”. But he is the author of the famous “Hello, World” program and many other UNIX programs).
For years the book “The C Programming Language, 1st edition” was the standard on the language C. In 1983 a committee was formed by the American National Standards Institute (ANSI)
to develop a modern definition for the programming language C (ANSI X3J11). In 1988 they delivered the final standard definition ANSI C. (The standard was based on the book from K&R 1st ed.).

The standard ANSI C made little changes on the original design of the C language. (They had to make sure that old programs still worked with the new standard). Later on, the ANSI C standard was adopted by the International Standards Organization (ISO). The correct term should there fore be ISO C, but everybody still calls it ANSI C.

Thursday, 3 January 2013

.NET

.NET FRAMEWORK

If were able to describe the C# language and its associated environment the .NET framework as the most important new technology for developers for many years.we would not be exaggerating .Net is designed to new environment within which you can develop almost any application to run on windows and possibly in future on other platforms,while C# is a new programming language that has been designed specifically to work with .NET .Using C# you can,for example ,write a dynamic web page ,a component of a distributed application ,a database access component ,or a classic windows desktop application.

THE SIGNIFICANCE OF .NET

In order to understand the significance of .Net it is useful to remind ourselves of the nature of many windows technologies that have appeared in the last ten years or so.In that time ,we've progressed on the home PC side from Windows 3.1(introduced in 1992) through to windows 95,98 and the most recently the Millennium Edition .Ont the business side,we've seen Windows NT 3.55,NT 4.0 and windows 2000,while Windows XP is set to cater for both home and business users.


SO WHAT IS .NET?
.Net is two things.First,its a library -and one that is just as extensive as the windows API.you can use it to call up all the same sort of feathers that have traditionally been the role of windows operating system;Displaying windows and dialog boxes,verifying security credentials,calling on base operating system services,creating threads,and so on,as well as newer areas such as accessing databases or connecting to the internet or providing web services .Unlike the old windows API however which was basically a huge set of C function calls the .Net library is fully object oriented 

Second the .Net provides the environment in which your program is run.we generally talk about the .Net run time as known as the CLR COMMON LANGUAGE RUN TIME which really means the software that deals with the execution of your program.when.Net -aware code is executed,it will be the.Net run time which startsup your code,manages the running threads,provides various background services,and in real sense is the immediate environment seen by the code.NET as something that provides level of abstraction from operating system.



ADVANTAGES OF .NET  

we've gone on in general terms about how great .Net is but we've said much about it helps to make your life as a developers easier.I'll define some of the improved features of .Net 

  • OBJECT ORIENTED PROGRAMMING
Object  Oriented programming OOP is a style of programming in which your code is broken up into units or parts  known as class and objects .Each  object usually abstracts some real world object that the application is concerned with.An object carries some state information as well as making methods available also allow you to base new object on existing objects by a process known as inhertance

  • GOOD DESIGN

What constitutes good design is.of course,subjective ,but Microsoft have taken a lot of trouble with .Net to consult developers and to learn from previous mistakes.The result is a base class library ,which is designed from the ground up in a highly intuitive way.In the vast majority of cases,you only have to look at the definition of a method to be able to see what if does and how to use it . that was certainty not true of the Windows API ,for which function are often not intuitive and often require a number of parameters that have to do with intricacies of the internal operation of the API or backward compatibility that with the aim of that function
As an example,creating and displaying a new windows with .NET means instantiating a form object perhaps setting a few properties on it,and calling its show() method.

  • LANGUAGE INDEPENDENCE
Although in the past COM component could communicate with each other no matter which  COM-aware language each one had been written in,there was still a large gulf between VB,Visual J++ and Visual C++.The data types were different ,and making a COM component available to any language meant putting severe restrictions on its method signatures,often in a way that would limit performance .And it was certainly not possible to mix the various language in the same code module 
All that has now changed with .NET all of the language VB.Net C#.NET and managed C++ compile to a common subset called the intermediate language.In the debugger ,for example you can step straight from C++ code into C# code,and from there into VB with out any problem.

  • BETTER SUPPORT FOR DYNAMIC WEB PAGES
Up to now ,the standard way of hosting dynamic web pages on windows has been using ASP.NET while ASP offers a lot of flexibility ,it is also inefficient due to its use of interpreted scripting languages,and the lack of object oriented design often result in messy ASP code.NET offers an integrated support for webpages,using a new technology -ASP.NET.With ASP.NET code in your pages is compiled and may be written in a .NET aware high-level language such as C# or VB.


  • DATA ACCESS

The .NET base class library is extremely extensive,including virtually full support for windows base services ,as well as for a number of component libraries .DATA accessing that was added to windows is a fundamental part of base class library from the start.A set of .NET components collectively known as ADO.NET,provides efficient access to relational databases and a variety of data resources.


  • SUPPORT WEB SERVICES
Web services are some thing that many people in the industry are convinces are going to be big business in the next few years The idea is that various methods on an object can be called across the internet via standard web protocols.This will bring a new meaning to distributed applications;It'll mean that companies will be able to provide services ,such as weather reports,parcel services ,credit card validation etc etc




  • C# 


The list of advantages of .Net wouldn't  be compile with out mentioning the fact that using .NET means you get to write a code in C# to write code in C# if you want to, C# is also a very good ,well designed language,which corrects a number of flaws that were present in existing language




INTEGRATED DEVELOPMENT ENVIRONMENT(IDE):
I'll just say a couple words about the development environment ,Visual studio.Net .Up to now,each language has effectively had its own independent developer environment  with in VS 6 package