Saturday 31 December 2016

C Program to find an Even or Odd Number

Program:
This program is saved as EvenOdd.c

Output:

Friday 30 December 2016

C Program for Addition of Two numbers

Program:
This program is saved as add.c

Output:

C program to print an Integer number on screen

Program:
This program is saved as PrintIneger.c

Output:

Sunday 25 December 2016

Structure of C program


1. /* This program........ */
The symbols /*........*/ used for comments. This comment are ignored by the compiler, and are used to provide useful information about program to humans who use it.

2. #include
This is a preprocessor which tells compiler to include stdio.h file.

3. main()
C programs consists of one or more functions. There must be one and only one main function. The brackets following the word main indicate that it is a function and not a variable.

4. { }
Braces surround the body of the function, which may have one or more instructions/statements.

5. printf()
It is a library function that is used to print data on the user screen.

6. "Hello World\n" is a string that will be displayed on user screen.
\n is the newline character.
; a semicolon ends a statement.

7. return 0;
 return the value zero to the Operating System.

NOTE: C is a case sensitive language, so the names of the functions must be typed in lower case as above. C programs are saved with .c extension.


Tuesday 20 December 2016

Features of Java

  1. SIMPLE: Java is simple especially compared to languages like C, C++. Java doesn't allow pointers, which was a complicated concept in C/C++. Java also doesn't allow operator overloading, goto statement etc. Java is easy to learn and its syntax quite simple and easy to understand.
  2. OBJECT-ORIENTED: Java is object oriented language means no program can be written without a class. An object oriented programming language needs to necessarily have classes and object. A class is a type of objects and an object is an instance of class.
  3. PLATFORM INDEPENDENT: Platform Independent means a program made for one platform will also work on any other platform. A platform is a combination of a system (computer), operating system and other packages with that system. Unlike other programming language such as C,C++ etc which are compiled into platform specific machines. Java is guaranteed to be write-once, run anywhere language. On Compilation Java program is compiled into bytecode. This bytecode is platform independent and can be run on any machine, plus this byte code format also provide security. Any machine with Java Runtime Environment can run Java Programs.
  4. DISTRIBUTED: This feature of Java was found to be very useful. Because of being platform independent, a Java based program can be distributed over internet and hence run on any platform (system) in the world. This feature of Java has made many things possible over the internet.
  5. DYNAMIC: Those things that happen during the compile time are called as static while those things that happen during the execution time are called as dynamic. Java has more dynamic features compared to C++.
  6. MULTI-THREADED: Java multithreading feature makes it possible to write program that can do many tasks simultaneously. Benefit of multithreading is that it utilizes same memory and other resources to execute multiple threads at the same time, like while typing, grammatical errors are checked along.
  7. GARBAGE COLLECTED: An object which is no more in use is automatically thrown in garbage by JVM. Thus the memory allocated to an object is automatically made free and available for other variables or objects. This removes the requirement of destructor as it was required in C++. In C++ the memory allocated to an object was to be made free by a destructor. In Java it is automatically done, hence garbage collected.
  8. ROBUST: Java has a very good inbuilt exception handling capacity that makes a Java program robust. Also, Java does not keeps the authority of memory allocation and de-allocation with the programmer. JVM automatically allocates and frees up the memory allocated for an object. Hence a software made on Java will not crash so easily as it would do on a C/C++ based software.
  9. SECURE: When it comes to security, Java is always the first choice. With Java secure features it enable us to develop virus free, temper free system. Java programs always runs in Java runtime environment with almost null interaction with system OS, hence it is more secure.
  10. INTERPRETED: Java programs are said to be interpreted. Java programs are converted into a special byte code. This byte code is interpreted by the JVM. JVM interprets the byte code generated by the Java compiler. By interprets, it means that the JVM converts the byte code into the machine understandable code.
  11. PORTABLE: A program written in Java is portable i.e. it can be carried over anywhere on any computer. This is because the Java program is platform independent and hence can work on any computer.
  12. HIGH PERFORMANCE: Java enables high performance with the use of just-in-time (JIT) compiler.
  13. SCALABILITY: Java based programs are scalable over a huge number of systems besides computer. The team of Sun Microsystems Inc. had mainly developed this programming language tool for programming the systems used in consumer electronics like washing machine, microwave oven, etc. Hence this programming language can be used even in such independent systems and not just computers. Thus Java is said to be scalable over all systems.

Advantages of C

  • C is portable language.
  • C is the collection of lot of libraries.
  • C language is easy to learn.
  • C is widely accepted language.
  • C supports modular programming style.
  • C is native language of UNIX.
  • It is very efficient, It is popular and well understood.
  • It is easy for debugging, error finding, testing and maintenance because of structured programming.

Introduction of Java

Java is a simple and yet powerful object oriented programming language. Java is created by James Gosling at Sun Microsystems, Inc. in 1991. The first publicly available version of Java (Java 1.0) was released in 1995.

Java is defined by a specification and consists of a programming language, a compiler, core libraries and a run time machine (Java virtual machine). The Java platform is usually associated with the Java virtual machine and the Java core libraries.

Java Virtual Machine (JVM)
Java was designed with a concept of ‘write once and run everywhere’. Java Virtual Machine plays the central role in this concept. The JVM is the environment in which Java programs execute. It is a software that is implemented on top of real hardware and operating system. When the source code (.java files) is compiled, it is translated into byte codes and then placed into (.class) files. The JVM executes these bytecodes. So Java byte codes can be thought of as the machine language of the JVM. A JVM can either interpret the bytecode one instruction at a time or the bytecode can be compiled further for the real microprocessor using what is called a just-in-time compiler. The JVM must be implemented on a particular platform before compiled programs can run on that platform.

Java Runtime Environment (JRE) and Java Development Kit (JDK)
A Java distribution typically comes in two flavors, the JRE and the JDK. The JRE consists of the JVM and the Java class libraries. Those contain the necessary functionality to start Java Programs. The JDK additionally contains the development tools necessary to create Java programs. The JDK therefore consists of a Java compiler, the java virtual machine and the Java class libraries.



Introduction of C Programming Language

     The C programming language is a general-purpose, high-level language (generally denoted as structured language). C programming language was developed by Dennis Ritchie between 1969 and 1973 at Bell Labs.

     C is one of the most commonly used programming languages. It is used in all extents of application, mainly in the software development. Many software's and applications as well as the compilers for other programming languages are written in C also Operating Systems like Unix, DOS and windows are written in C.

     C has many powers, it is simple, portable and it can control System Hardware easily. C has been standardized since 1989 by the American National Standards Institute (ANSI).

Welcome

Welcome to my blog