Download presentation
Presentation is loading. Please wait.
Published byPauline Shaw Modified over 9 years ago
1
Introduction to Programming Languages
2
Problem Solving in Programming
3
Problem Solving Primitive and Higher calculations Computer programming is artifact (tool) used for the Problem solving mechanism via computers
4
Few Terms Program Programming Programability
5
Algorithm and program Algorithm is sequence of steps usually written in natural language readable for humans Programming is the algorithm translated in programming language so that computer can understand
6
Programming – By Example Mean of three Numbers Instructions Program Counter Fetch and Execute Cycle
7
Flow Charts
8
Is common type of chart used to represents an algorithm or process. The steps are shown in boxes of various kinds, and their order by connecting these with arrows. Flowcharts are used in analyzing, designing, documenting or managing a process or program in various fields.
9
Flowchart The notations for flowchart are Draw a flowchart that will compute the sum, average and product of three numbers. ProcessStart / End DecisionInput / Output T F
10
How to develop Algorithm Write Algorithm and draw flow chart of 10 numbers in a loop Table of 2 Factorial
11
Self Assessment Tasks Compute Average mean of three numbers input by the user Write table of two
12
Jumping to Programming Languages
13
History (Paradigms) Unstructured Languages Single continuous block of code e.g Assembly Structured / Procedural Languages Functions and procedures e.g C, Pascal, Fortran Object-Oriented Languages Real-world modeling (Attributes, Behavior) e.g C++, Java
14
Why we are going towards OOP? Object-oriented creatures Advantages: Simpler, easier to read programs More efficient reuse of code Faster time to market More robust, error-free code Concepts on the way ….
15
Problems in... Unstructured Programming ”go to” and jumps causing complexities Difficult debugging and maintainance Structured Programming Unrestricted access to global data New Datatypes creation No real world modeling Difficult maintainance Error prone.
16
Object Oriented Approach Data Encapsulation Data hidding Real world modeling Attributes = Data members Behavior = methods / functional members New Data Types Seperation Inheritance Polymorphism Abstraction Class A data functions A a; B b;
17
some basic questions?? What are the objects in OOP? What should be the objects in the design of an object-oriented program? Is OOP better than previous programming paradigms?
18
How will I understand?????
19
Computer and Humans Computers understand 0’s and 1’s High level Language Machine level Language
20
Execution of a Program Object Code Source Code Other Object Files Linker.exe file Execute Output 010101010 101010101 101000000 …… Compiler
21
MyProg.class MyProg.java Compiler Other class Files Linker A2 HJ JI NJ JI JO JO 99 O1 JAR Archive public class Sample { public void main() { println( “hello”); } A2 N8 BH HJ BK JI KO O9 NJ JK L8 J9 JI JO KJ KO K3 K9 98 90 …. AB CD F3 S6 JS JH N9 J5 33 JVM hello Java Interpreter
24
Java OOP language developed by SUN Microsystems Java is compiled into bytecodes Bytecodes are high-level, machine-independent instructions for a hypothetical machine, the Java Virtual Machine (JVM) The Java run-time system provides the JVM Extensive networking facilities Extensive set of APIs for GUIs, distributed computing, 2D/3D graphics, mail, and others Portable: Write Once, Run Anywhere Multithreading support built into the language
25
Java Features Automatic garbage collection No manual memory allocation and deallocation Never have to worry about memory leaks No pointers or pointer arithmetic No off-by-one bugs Arrays are first-class objects Array bounds are always checked Multiple inheritance replaced by interfaces Eliminates complexities of multiple inheritance
26
Java Virtual Machine Java is compiled into bytecodes Bytecodes are high-level, machine-independent instructions for a hypothetical machine, the Java Virtual Machine (JVM) The Java run-time system provides the JVM The JVM interprets the bytecodes during program execution Since the bytecodes are interpreted, the performance of Java programs slower than comparable C/C++ programs But the JVM is continually being improved and new techniques are achieving speeds comparable to native C++ code
27
JVM All Java programs run on top of the JVM JVM was first implemented inside Web browsers, but is now available on a wide variety of platforms JVM interprets the bytecodes defined in a machine- independent file format called a class file
28
Types Of Java Programs Application Standalone Java program that can run independent of any Web browser Applet Java program that runs within a Java-enabled Web browser Servlet Java software that is loaded into a Web server to provide additional server functionality
29
Instructions for Java Installation Download and Install JDK NetBeans 6.7.1
30
Refference Book The Complete Reference Java 2 Fifth Edition. By Herbert Schildt
31
Hello World class HelloWorld { public static void main(String args[]) { System.out.println("Hello World"); }
32
Factorial public class Factorial2 { public static void main(String args[]) { int n = 3; int fact = 1; for (int c = 1 ; c <= n ; c++ ) fact = fact*c; System.out.println("Factorial of "+n+" is = "+fact); }
33
Table of Two or not ? public class tables { public static void main(String args[]) { for (int i = 1; i <= 10; i++) { for (int j = 1; j <= 10; j++) { System.out.print(i + "x" + j + "=" + (i * j) + "\t"); } System.out.println(); } }
34
Tables Output
35
Tasks Just print Table of Two. Find Factorial with proper solution as output like 5! = 5 x 4 x 3 x 2 x 1 = 120. Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,... Write a program to find out if a number is prime?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.