Friday, 29 May 2015

Data Types In Python

By With No comments:
Data types using we can different types of data stored in memory. For example, we can stored employee name using alphanumeric character  types and her age and id are  numeric types. These all types of data stored in python using data types.

Python Provide Five Types Of Data Types Such As :
  • Numbers
  • String
  • List
  • Tuple
  • Dictionary
Python Numbers  :

Python numbers data types store numeric values. In python number data types in we have use integer numbers, floating points numbers, and complex numbers.

Example

abc  =  10
abc1  =  20.52
abc2  =  45.e

Here example in we show first variable abc in we stored 10 numeric values, second variable abc1 in we stored 20.52 floating point values and third variable abc2 in stored 45.e complex number, so we understand numbers data types in we can stored integer, floating point and complex number.

Python String  :

String data types in python represents text information in our python program. Strings in python we can create using single quotes or double quotes. Anything within quotes is a string in python.

Example

abc  =  ‘Hello world’
abc1 =  “Hello friends”
print abc
print abc1

Output

Hello world
Hello friends

Python Lists  :

Python in list data type is mutable. This means that the elements in a list can be changed after it is created. The list can contain mixed data types. List contain items separated by commas and enclosed with in square brackets ([]).

List is similar functionality of arrays in c language but small difference is array stored same type of data and list is stored different data types.     
List in stored elements are access using the slice operator ( [ : ] ) with index position start with 0.

Example

lst = [123, ‘abc’, 50.20, ‘xyz’]
print lst
print lst[0]
print [0:2]
print[1:]

Output

[123,  ‘abc’, 50.20, ‘xyz’]
123
[123,  ’abc’]
[ ‘abc’, 50.20, ‘xyz’]

Python Tuples  :

Python in tuples is an immutable data types. A tuple consists of a number of values separated by commas, like list. Tuples are enclosed with parentheses ( () ).

The difference between tuples and list is :
  • Tuples enclosed with parentheses ( () ) and list enclosed with in square brackets( [] ).
  • Tuples is immutable type and list is mutable type of data types.


Example

tuple  =  ( 123, ‘abc’, 50.20, ‘xyz’, 286)       
print tuple                                   
print tuple [ 0 ]                            
print tuple [ 1 : 3 ]                      
print  [ 2 : ]                                   

Output

( 123, ‘abc’, 50.20, ‘xyz’, 286)
123
( ‘abc’, 50.20 )
( 50.20, ‘xyz’, 286 )

Python Dictionary  :

Python in dictionary data types are kind of hash table type. Dictionary is a group of key-value pairs. The elements in a dictionary are indexed by keys. Keys is unique in dictionary data types.
Dictionaries are enclosed by curly brackets ( { } ) and element of dictionary access using square brackets ( [ ] ).     

Example

dic  =  { }
dic [ ‘one’ ]  =  “First Position”
dic [3]  =  “Third Position”
dict1  =  { ‘ Name ’ :  ‘ James  ’, ‘ Pin  ’: 385001, ‘ Designation ’:  ‘ Engineers ’  }
print  dic [ ‘ one ’ ]
print dic [ 3 ]
print dict1
print dict1.keys()
print dict1.values()

Output

First Position
Third Position
{ ‘ Name ’ :  ‘ James  ’, ‘ Pin  ’: 385001, ‘ Designation ’:  ‘ Engineers ’  }
{ ‘ Designation ’, ‘ Pin  ’,  ‘ Name ’}
{ ‘ Engineers ’,  385001, ‘ James ’ }

Data Types In C

By With No comments:
In c programming language any of the data should be declare before it can be used in program. Data types in c are used for assigning a type to a data. Data Types of any variable define how much space occupies in memory storage.

Data Types In C

Data types in c can be classified as follows :
      
                  1)      Basic Data Types
·         Integer types
·         Floating Point Types
·         Character Types
                 2)      Derived Data Types
·         Arrays
·         Pointer
·         Structures
·         Union Types
·         Function Types

Integer Data Types

Integer data types is used when the declare variable with integer type. We can declare integer data type using the “int keyword.

Example

int abc;
Here, int is integer data type and abc is the variable.

Following detail about integer types with storage sizes and value ranges. 

Data Type


Storage Size

Value Range
Char
1 byte
-128 to 127 or 0 to 255
unsigned Char
1 byte
0 to 255
signed Char
1 byte
-128 to 127
int
2 or 4 bytes
-32,768 to 32767
unsigned int
2 or 4 bytes
0 to 65,535
Short
2 bytes
-32,768 to 37,767
unsigned short
2 bytes
0 to 65,535
Long
4 bytes
-2,147,483,648 to 2,147,483,647
unsigned long
4 bytes
0 to 4,294,967,295

Floating-Point  Data types

Floating point data type stored floating point values such as 1.25, -65.20, 0.55 etc. We can declare floating point data types using “float” or “double” keyword.

Example

float abc1;
double abc2;

Here float and double are floating point data types define and abc1 and abc2 are variable. Main difference between float and double are sizes because float size is 4 bytes and double size is 8 bytes.

Following detail about floating-point types with storage sizes and value ranges.

Data Type


Storage Size

Value Range
float
4 bytes
1.2E-38 to 3.4E+38
double
8 bytes
2.3E-308 to 1.7E+308
long double
10 bytes
3.4E-4932 to 1.1E+4932

If we want to get exact size of the data types in c language so we use the sizeof operator. Sizeof operator return the size of data types.

Example

#include <stdio.h>
#include <float.h>
 int main()
{
printf(“Size of integer type is  :  %d \n”, sizeof(int));
printf(“Size of float type is : %d” , sizeof(float));
return 0;
}

Output

Size of integer type is  :  4
Size of float type is  :  4

Thursday, 28 May 2015

Constructor In Java

By With No comments:
Constructor is special type of method in java used to initialize the object. Constructor is invoked at the time of object creation.

Rules For Creating Java Constructor

Basically two things keep in mind when we create constructor such as :
      1)  Constructor name must be same as its class name
      2)   Constructor must have no explicit return type   

Types OF Constructor In Java

There are two types of constructor in java such as:
       1)      Default Constructor
       2)      Parameterized Constructor

Default Constructor In Java

A constructor that have no parameter(argument) is known as default constructor.

Syntax Of Default Constructor

class_name()
{
  //  Code Of Block
}

Example Of Default Constructor

class Hello
{
Hello()              // Default Constructor
{
System.out.println(“Hello World”);
}
Hello obj = new Hello();
}

Output

Hello World

Parameterized Constructor In Java

A constructor that have parameters (arguments) is known as parameterized constructor. It is used when we give different values to distinct object.

Syntax Of Parameterized Constructor

class_name(parameter1,parameter2,……….)
{
  //  Code Of Block
}

Example Of Parameterized Constructor

class Emp
{
int empid;
String name;
Emp(int I,String n)
{
empid = I;
name = n;
}
void show()
{
System.out.println(empid+“  ”+name);
}             
public static void main(String ar[])
{
Emp e = new Emp(1,“john”);
Emp e1  = new Emp(2,”david”);
e.show();
e1.show();
}
}

Output

1 john

2 david

Wednesday, 27 May 2015

Components Of Java Development Kit (JDK) In Java

By With No comments:
Before you can start writing java program, You need to install some kind of java programming software (tools).

Components Of JDK (Java Development Kit) Are :           

Java Compiler Java Compiler use for converts source code into java bytecode. Java compiler component of jdk is used in java programming using “javac” command.  
Java Interpreter – Java interpreter is the loader for java applications. It is used for Interpret the java file that are compiled by java compiler. Java interpreter component of jdk is used in java programming using “java” command.

Java Applet Viewer – Java applet viewer is can be used to run and debug java applets without a web browser.  Java applet viewer component of jdk is used in java programming using “appletviewer” command.

Java Documentation – Java documentation is automatically generates documentation from source code. It is need for java program in easy maintenance of program code. Java documentation component of jdk is used in java programming using “javadoc” command.

Java Header File Generator – Java header file generator is used to produce the header file with implement native methods. Java header file generator component of jdk is used in java programming using “javah” command.

Java Disassembler – Java disassembler is used to enables us to convert bytecode files into a program description. In other word, It is used to disassemble java class file. Java disassembler component of jdk is used in java programming using “javap” command.

Java Debugger – Java debugger is check our program and find error in our program. Java debugger debug the java file. Java debugger component of jdk is used in java programming using “jdb” command.

Tuesday, 26 May 2015

Basic Concept Of Object-Oriented Programming In C++

By With No comments:

Object-oriented programming(oop) is simply a manner of thinking about the problem space of the system to be develped.
These Includes :

Object 


Object is the basic runtime entities in object oriented programming.They are also represent real world entity such as a perseon, a place, a bank acount, a table of data and any of the item that handle by program.
Object containing information about data and code to manipulate the data.Object can intract without having to know the details of each others code of block that exist in the class.

Class 


Class is a blueprint of related data members and methods.In other words, class is the self contained independent collection of the data member and methods, which create because perform specific task.
Once class has been defined, we can create any number of object of that class. A class is the collection of similar types of objects. Each object in class are associated with class.For example, fruite is define as a class and members of fruite class are mango, apple, and orange.

Data Abstraction And Encapsulation 


The wrapping up of data and functions into a  single unit is known as encapsulation. In the data encaptulation in data is not accessible to outside world and only those functions which are wrapped the class can access it.
This insulation of data from direct access by the program is called data abstraction or data hiding.
Abstarction is process of representing essential features without including the background details. 

Inheritance 


Inheritance is the process of which objects of one class acquires the properties of objects of another class.
Inheritance supports the concept of  hierachical classification.
Inheritance in we can add addition features to an existing class without modified it.

Polymorphism 


Polymorphism is the greek language word it means ability to take more than one form. In Polymorphism operations may exhibit different behavior is different instances. The behavior depends upon the types of data used in the operations.

Thursday, 30 April 2015

Structure Of C Programs

By With No comments:
 All the C Program are divided into many parts such as :
        Preprocessor Commands
        Functions
        Variables
        Statements and Expressions
        Comments

Preprocessor Commands :-

           Preprocessor Command is not a part of the compiler of c language but it is a diffrent step in the compilation time. All preprocessor commands starts with a (#) symbol.

Example :-

#define               Substitutes a preprocessor macro      
#include             Inserts a particular header from another file  
#undef                Undefines a preprocessor macro        
#ifdef                  Returns true if this macro is defined     
#ifndef                Returns true if this macro is not defined
#if                       Tests if a compile time condition is true
#else                    The alternative for #if
#elif                     #else an #if in one statement
#endif                  Ends preprocessor conditional
#error                  Prints error message on stderr
#pragma              Issues special commands to the compiler, using a standardized method

Main() Function :-

                we all know why main  function is used in c programs because when we run the program at that time program execution start with the main Function.

Syntax :-

int main()
{
// code write here
return 0;
}

Comments :-

         Comments are the statements that are ignored by the  compiler.

Syntax :-
                Multiline Comments :-
                /*    
                                  Comments statement that put here
                */
                Singleline Comments :-
                //     Comment statement put here for single line comments


Example of Hello World Program :-

#include<stdio.h>            //Preprocessor Commands
int main()                         //main()   program execution start to here
{
/* hello word program in c    */         //comments statements
printf(“Hello World…..\n”);    
return 0;                      

}