Thursday 11 December 2014

Age Math Trick

Interesting Trick:

1. Multiply your age with 259
2. and then Multiply answer with 39.
now see the result, its amazing na?

Monday 18 August 2014

Stop window resizing in VLC media player.

Go to
1. Tools
2. Preferences or (ctrl+p)
3. Interface settings
and uncheck "resize interface to video size".


thank u..

Monday 11 August 2014

C language program to find out the factorial of an integer by calling a function.

#include<stdio.h>
void main()
{
          long int n;
          long int fact(long int n);
          clrscr();
          printf(" Enter a number: ");
          scanf("%ld",&n);
          printf(" Factorial of %ld is %ld",n,fact(n));
          getch();
}
long int fact(long int i)
{
          int fct=1;
          for(;i>=1;i--)
          fct*=i;
          return fct;

}

Wednesday 6 August 2014

C language program to find out the factorial of an integer by using "while" loop.

#include<stdio.h>
main()
{
          double n,ans=1;
          clrscr();
          printf(" Enter a number\n to find factorial of it : ");
          scanf("%lf",&n);
          while (n>1.)
          {
          ans*=n;
          --n;
          }
          printf(" answer = %.2lf",ans);
          getch();

}

C language program to find Prime Number.

#include<stdio.h>
#include<math.h>
void main()
{
          int num,i,is_prime=0;
          clrscr();
          printf(" Give a number : ");
          scanf("%d",&num);
          for (i=2;i<=sqrt(num);i++)
          {
          if (num%i==0)
          {
          is_prime=1;
          break;
          }
          }
          if (is_prime==1)
          printf(" Not prime number");
          else
          printf(" Prime number");
          getch();
}

Monday 4 August 2014

What is computer?

Computer:
            Computer is an electric device, which is used in almost all fields of life. Computer receives instruction or data through input devices. It works on these instructions in processor and provides meaningful results through output devices. A computer can be divided into three main units.
Input units:
            Such parts of computer through which a computer can receive data are called input units. E.g.: keyboard, mouse, microphone etc.
OR
The device from that a computer receives instructions is known as input device. Data in any form is first digitized, i.e. converted into binary form by the input devices before being fed to the CPU. This unit is also called the “receiving section” of a computer system.
Keyboard:
            It is one of the most useful input devices. It provides convenient to feed data in a computer. A computer keyboard is similar to an electronic typewriter keyboard with little modification. It has some additional keys like function keys, arrow keys, numeric keys etc.
Mouse:
            Mouse is a pointing device which is use to select an option and have two buttons to click on any option. Now a days laser type mouse is used.
Scanner:
            It scans the image of the information exposed to it and conveys these to computer’s memory for further processing.
Light pen:
            The light pen looks like an ordinary pen, but its tip is light sensitive detector. It is use to write/indicate information directly on monitors screen. When tip of the pen touched the surface of screen, the computer locates its position in the form of x-y coordinates of that point. A wire to CPU connects this pen. The written information is, at the same time conveyed to memory also. For example, you might have seen a circle drawn around a fielder during cricket match telecast. This circle is drawn by the light pen.
            Magnetic tape and cartridges are used to input data into computer for various applications.
Output devices:
            Such part of a computer where by a computer provides us the results of processing are called output units. The output units receive the data from CPU in the form of binary bits. Some common output deices are listed below.
Monitor:
            The results are termed as output from computer, output is displayed on a device that is similar to TV and is called monitor known as VDU (visual display unit). The data can be presented on the screen either as words, numbers, graphics, tables or diagrams. Monitor use the technology of cathode ray tube (CRT). Usually it is of 14” screen size when measured diagonally and has a 25*80 (25 rows and 80 character per row) display. Display of output on monitor is power dependent, vanishes when power is switched off. Many different types of monitor are in common use. These may be of VGA, SVGA, MVGA and EVGA   types, depending on the resolution.
 They are.
Paper white monitor:
            A display monitor in which text and graphics character are displayed in black against the white background to resemble the appearance of printed page. Some manufacturers
Monochrome monitor
Color monitor
 E.g. monitor, printer, plotter etc.
Processing unit:

            This is the main part of a computer therefore it is also called the brain of computer system. It is contained on a single integrated circuit or “chip”. All jobs of processing are carried out in this unit that is also called (C.P.U) central processing unit.

A C language program to print Triangle of asterisks (*).


#include<stdio.h>
void draw_j(void);
void main()
{
          clrscr();
          draw_j();
          getch();
}
void draw_j(void)
{
          int a,s;
          for(a=5;a>=1;a--)
          {
          s=1;
          while (s<=a)
          {
          printf("*");
          s++;
          }
          printf("\n");
          }
}

OUTPUT:
********
*******
******
*****
****
***
**

*

Friday 25 July 2014

A C language program that promotes the user to enter a number and then reverse it.


For example, if the user enters 5143, the function would reverse it so that it becomes 3415.

#include<stdio.h>
void main ()
{
          int num=0;
          clrscr();
          printf(" Enter a number to reverse : ");
          scanf("%d",&num);
          printf(" Reverse of %d is %d\n",num,reverse(num));
          getch();
}
int reverse(int num)
{
          int res=0,temp=num,k,a=0,i;
          /* finds the number or digits*/
          for(;temp/10!=0;temp/=10)
          a++;
          for(;num/10!=0;)
          {
          k=num%10;
          for(i=0;i<a;i++)
          {
          k*=10;
          }
          num/=10;
          a--;
          res+=k;
          if (num<10)
          res+=num;
          }
          return res;

}

Examples of loop with output in java code

class Loops
{
                public static void main(String args[])
                {
                                int i;
                                for(i=0; i<10; i += 2)
                                System.out.print(" " + i);
                                System.out.println();

                                for(i=100; i>=0; i -= 7)
                                System.out.print(" " + i);
                                System.out.println();

                                for(i=1; i<=10; i += 1)
                                System.out.print("*" + ++i);
                                System.out.println();

                                for(i=2; i<100; i *= 2)
                                System.out.print(" " + i);
                }
}
Output:
0 2 4 6 8
100 93 86 79 72 65 58 51 44 37 30 23 16 9 2
*2*4*6*8*10

2 4 8 16 32 64

Thursday 24 July 2014

Calculate square of odd, cube of even , quotient for multiple of 7 with java code.

import javax.swing.*;
class Cal
{
                public static void main(String args[])
                {
                                int n;
                                n = Integer.parseInt(JOptionPane.showInputDialog("enter a value: "));
                                if (n%2==0)
                                {
                                System.out.println("cube of even value = " + n*n*n);
                                JOptionPane.showMessageDialog(null, "cube of even value = " + (n*n*n));
                                }
                                else if (n%2!=0)
                                {
                                System.out.println("square of odd value = " + n*n);
                                JOptionPane.showMessageDialog(null, "square of odd value = " + (n*n));
                                }
                                if (n%7 == 0)
                                {
                                System.out.println("quotient for 7 is " + n/7);
                                JOptionPane.showMessageDialog(null,"quotient for 7 is " + (n/7));
                                }
                                System.exit(0);
                }

}

Wednesday 23 July 2014

Algorithm analysis

An algorithm is a well-ordered collection of unambiguous and effectively computable operations that when executed produces a result and halts in a finite amount of time [Schneider and Gersting 1995].
          Internal Sort
        The data to be sorted is all stored in the computer’s main memory.
          External Sort
        Some of the data to be sorted might be stored in some external, slower, device.
          In Place Sort
        The amount of extra space required to sort the data is constant with the input size.
A problem is said to be intractable if solving it by computer is impractical
•Example: Algorithms with time complexity O(2n)take too long to solve even for moderate values of n; a machine that executes 100 million instructions per second can execute 260 instructions in about 365 years
Constant Time Complexity
•Algorithms whose solutions are independent of the size of the problem’s inputs are said to have constant time complexity
•Constant time complexity is denoted as O(1)
Selection Sort Algorithm
•The algorithm has deterministic complexity
-all possible instances of the problem (“best case”, “worst case”, “average case”) give the same number of operations T(n)=n2–n=O(n2)
characteristics of algorithms.
Algorithms are well-ordered.
Algorithms have unambiguous operations.
Algorithms have effectively computable operations.
Algorithms produce a result.
Algorithms halt in a finite amount of time.
Quick sort: it is the one of the earlier divide and conquer algorithm to be discovered. It was published by C.A.R Hoare in 1962. It is still one of the fastest in practice.
Basic operation:
To analyze an algorithm we can isolate a particular operation fundamental to the problem called basic operation.
Complexity or work done by an algorithm:
Number of instruction executed or the number of storage bits used by a program can be taken as complexity measure.
Complexity depends upon number of inputs.
Analysis of algorithm: criteria
a.       Correctness
b.      Amount of work done (complexity of work done)
Complexity mean the amount of work done, measured by some specified complexity measure, for example the number of basic operation performed. Complexity has nothing to do, with how complicated or tricky an algorithm is; a very complicated algorithm may have low complexity.
Worst-case complexity:
The function W(n) is called the worst-case complexity of the algorithm. W(n) is the maximum number of basic operations performed by the algorithm on any input of size n. determination of W(n) is called worst-case complexity analysis.
The worst-case complexity is valuable because it gives an upper bound on the work done by the algorithm. The worst-case analysis could be used to help form an estimate for time limit for a particular implementation of an algorithm.
c.       Amount of space used
d.      Simplicity clarity
e.      Optimality

Generalized searching routine: it is a procedure that processes an indefinite amount of data until it either exhausts the data or achieves its goal.

Show first 10 Fibonacci numbers in message dialog box with java code.

import javax.swing.*;
class Fibo
{
                public static void main(String[] args){
                int n1 = 0,n2 = 1,n3;
                String st;
                st = n1 + "\n" + n2 + "\n";
                for(int i = 1; i<10; i++){
                                n3 = n1 + n2;
                                st += ( n3 + "\n");
                                n1 = n2;
                                n2 = n3;
                }
                JOptionPane.showMessageDialog(null, st);
                System.exit(0);
                }                             

}

Tuesday 22 July 2014

Object Oriented Programming

Object Oriented Programming:
OOP is a technique in which programs are written on the basis of objects. OOP language is an easy and flexible approach for designing and organizing the program. The program is designed by using classes. It helps in developing the software, which is modular, understandable, more readable and importantly reusable.
Features of OOP:
Class:
This is a logical representation of objects.
Or it is just like a map/ model that describes the structure of related objects.
Or it is a unit which consists of properties/ attributes/ data and member functions/ methods. The data items and functions are defined within the class. A class is the significant feature that makes any language an OOP language. This is fundamental building block of object oriented program.
Object:
It is physical implementation of a class.
Or anything having physical/ real existence.
The variables or instances of a class are called objects. Object of a class consists of both the data members and member function of the class.
The member functions are used to process and access data of the object.
Each time that you create a new object, it must be based on a class. For example, you may decide to place three buttons on your form. Each button is based on the Button class and is considered one object, called an instance of the class. Each button (or instance) has its own set of properties, methods, and events.
Examples of objects are forms and controls. Forms are the windows and dialog boxes you place on the screen; controls are the components you place inside a form, such as text boxes, buttons, and list boxes.
Properties:
The characteristics of an object are called its properties.
Properties tell something about or control the behavior of an object, such as its name, color, size, or location. You can think of properties as adjectives that describe objects.
Action/ behavior/ methods/member function:
                Any activity performed by the object to achieve some task. These are verbs of OOP. Some typical methods are Close, Show, and Clear. Each of the predefined objects has a set of methods that you can use.
Encapsulation:
                The combining of data members and member functions into one unit is called encapsulation.
Information/data hiding:
                To conceal/hide the data from the outside of class.
The data of one object is hidden for the other objects of the program. This is called data hiding. The data hiding and data encapsulation are main features of OOP. The access specifier “private” is used to hide data.
Inheritance:
                The process of creating new class from already created class. Already existed class is also called super class / parent class / base class.  Newly created class is called child class / sub class / inherited class / derived class.
Advantages of inheritance:
·         reusability of the code
·         reliability of the code increases
·         easy to derive the enhance class from the existing
·         easy to represent object in the real world with the usage of inheritance
·         Effort required to derive the new class is minimized.

Reusability:
OOP provides ways of reusing the data and code. Inheritance is a technique that allows a programmer to use the code of existing class to create new class. This saves time for writing and debugging the entire code for a new class.
Abstraction:
                This is a technique used to represent real world things in class.
                Or The ability to create an abstract representation of a concept in code.
Overloading:
                The art of taking multiple functionality from the single feature.

  • Overloaded-members provide different versions of a property or method that have the same name, but that accept a different number of parameters (or parameters of different types).
  • Overridden-properties and methods are used to replace an inherited property or method. When you override a member from a base class, you replace it. Overridden members must accept the same data type and number of arguments.
  • Shadowed-members are used to create a local version of a member that has broader scope. You also can shadow a type with any other type. For example, you can declare a property that shadows an inherited method with the same name.

Difference between Encoding and Modulation

• Modulation is about changing a signal, whereas encoding is about representing a signal.

• Encoding is about converting digital or analog data to digital signal, whereas modulation is about converting digital or analog data to an analog signal.

• Encoding is used to ensure efficient transmission and storage, whereas modulation is used to send the signals to a long way.

• Encoding is mainly used in computers and other multimedia applications, whereas modulation is used in communication mediums such as telephone lines and optical fibers.

• Encoding is about assigning different binary codes according to a particular algorithm, but modulation is about changing the properties of one signal value according to certain properties (Amplitude, Frequency, or Phase) of another signal.

Monday 21 July 2014

The .NET Framework

In July 2000, Microsoft announced a whole new software development framework for Windows called .NET in the Professional Developer Conference (PDC). After releasing of different Betas of .NET, finally in March 2002 Microsoft released final version of the .NET framework.
.NET is a name for a new strategy for building application for the next decade. The .net framework is an enormous collection of functions for any programming task. It contains all the functionality of the operating system and makes it available to application through numerous methods.
The programming languages in Visual Studio run in the .NET Framework. The Framework provided for easier development of Web-based and Windows-based applications, allows objects from different languages to operate together, and standardizes how the languages refer to data and objects. Several third-party vendors have announced or have released versions of other programming languages to run in the .NET Framework, including .NET versions of APL by Dyalog, FORTRAN by Lahey Computer Systems, COBOL by Fujitsu Software Corporation, Pascal by the Queensland University of Technology (free), PERL by ActiveState, RPG by ASNA, and Java, known as IKVM.NET. The .NET languages all compile to (are translated to) a common machine language, called Microsoft Intermediate Language (MSIL). The MSIL code, called managed code, runs in the Common Language Runtime (CLR), which is part of the .NET Framework.

VisualStudio.NET is the environment that provides all the necessary tools for developing applications. The language is only one aspect of a windows application.

What is Java?

The word java is a long term of coffee. Java is a purely object oriented programming. It enhances and refines the object oriented paradigm used by C++. In internet programming, Java is a revolutionary force that will change the world, as similar like C was in system programming. The main objective behind the development of Java is portability and plat form independents language.
So that it could produce such type of codes that would run on variety of CPUs under different environment.
            As C++ provides this facility but for running a program of C++ on any type of CPU we need a full C++ compiler on that particular CPU. But the problem is that the compilers are expense and time consuming to create.

            Java is both interpreter and compiler based language. 

Thursday 17 July 2014

Write, save, compile and run simple java program in command prompt.

Write, save, compile and run simple java program in command prompt.

step 1

open notepad.

step 2

write any code for java program.

save with java format in bin folder of jdk.

step 3

open cmd and go to bin folder.

step 4

use javac command to compile java file
after compilation class file will be created.

step 5

use java command to run java program(class file).

keep visiting www.h-programmer.blogspot.com for more interesting posts.
thank you.



java by Hamayun Aziz