Monday, December 12, 2011

Your First Program

Don't know anything about programming don't worry as you read this blog u will learn to program within few weeks and most importantly you will enjoy it.So , you have decided to learn programming so first you need to know what is a program.A program is an implementation to an algorithm,so whats an algorithm ,it is a set of steps written to perform a particular task.like, an algorithm to add two numbers. Step 1:Take the first number. Step 2:Take the second number. Step 3: add them . Step 4:Display the result. So, to implement the above algorithm in a program you need to choose a programming language and since C is a basic programming language and yet very powerful we choose C , to start the programming. You just need to know a few things to use C,they are: 1.Variables : they store data. 2.Datatypes:they represents the type of data stored. 3.Operators: they are used for manipulations. Lets start with implementing the algorithm. int a=10; int b=20; int c=a+b; printf("%d",c);

Sunday, November 20, 2011

for each

Guess the output: public class ForEachDemo { public static void main(String args[]){ int a[]={1,8,1,1,1,1,1,1,1,1}; for(int i:a)//for each is for arrays display System.out.println(a[i]); } } Output: 8 1 8 8 8 8 8 8 8 8




Guess the output: public class ForEachDemo { public static void main(String args[]){ int a[]={1,8,1,1,1,1,1,1,1,1}; for(int i:a)//for each is for arrays display System.out.println(i); } }
output:
1 8 1 1 1 1 1 1 1 1

Sunday, November 13, 2011

processing streams

perform some sort of operation such as buffering or encoding as they reaad and write.

Data sink stream

they are used to read from or write to specialized data sink such as files pipes strings.

java.io package

contain all classes that are required to handle input and output

character stream

reader and writer stream are character stream

byte stream

Input and output stream are byte stream.eg:images ,sounds.
2 types:
1.ObjectInputStream
2.ObjectOutputStram

System.err

System is a class in java.lang package and contain a predefined stream variable err.
refers to standard error stream which is also console

it is object of type PrintStream.
it is a byte stream.

System.in

System is a class in java.lang package and has a predefined stream variable in.
refers to standard input that is keyboard.
it is an object of type input stream.
it is a byte stream

System.out

System is the class name and out is a predefined stream variable.
refers to standard output stream which is console
it is object of type PrintStream.
it is a byte stream.

stream

java provide input and output through stream.
Streams are ordered sequence of data that have a source or destination. two categories
1.character stream
2.byte stream

character stream

convenient means of handling input and output data.

byte stream

is used for reading and writing of binary data.

Sunday, November 6, 2011

java program to add 2 numbers

//add this program to your package class addnum { public static void main(String [] args) { int number1=Integer.parseInt(args[0]); int number2=Integer.parseInt(args[0]); System.out.println(number1+number2); } } /* run the program and enter 2 integer values like, 4 5 output: 9 */

java program to add 2 strings

//include this program in your package class calc { public static void main(String args[]) { System.out.println(args[0]+args[1]); } } /*run the program and enter 2 strings like,abc def output:abcdef */

Saturday, October 29, 2011

list in java

List is present in java.util .It is an interface.List can implement vector.

virtual function

In Java a function can be made virtual by just attaching the keyword virtual to implement polymorphism.Eg:- class any { int a; float b; virtual void show() { System.out.println("a="+a+"\n b="+b); } } class many extends any { int a1; float b1; void show() { Syatem.out.println("a="+a+"\n b="+b); } public static void main() { any *ptr; many *ptr1; ptr=&ptr1; ptr->show(); ptr->show(); } }

Monday, October 24, 2011

link list creation

A link list is a way to represent data so that each element points to next element. steps to create a link list. 1.create a structure : struct linkl { char name[20]; int number; linkl *next; }; two data members name and number are created and a self referential pointer next is created.

Wednesday, May 11, 2011

usb

universal serial bus .... establish communication between a device and a PC

dvd

digital versatile disc commonly stores 4.7 GB

ip address

internet protocol address .... is a numerical label to a device attached to network.

ec2-user@ec2 Permission denied