Wednesday, November 30, 2016

looping with goto

looping with goto

syntax:

label: 
if ( condition?)
{
.
.
.
goto label;
}
writing loop using goto is non standard c language programming practice.
nowadays computers uses virtual Memory Systems(Hard disk assumed as RAM)

if we use goto it need  more swappings from RAM to HARD DISK vice versa.

That's why goto is not preferred.

Labels:

Thursday, November 24, 2016

II BTECH II SEM JAVA PROGRAMMING LAB SYLLABUS ( R13 )

II BTECH II SEM JAVA PROGRAMMING LAB SYLLABUS ( R13 )

JAVA PROGRAMMING LAB
1. Write a JAVA program to display default value of all primitive data types of JAVA
2. Write a JAVA program that displays the roots of a quadratic equation ax2+bx+c=0. Calculate the
discriminent D and basing on the value of D, describe the nature of roots.
3. Write a JAVA program to display the Fibonacci sequence
4. Write a JAVA program give example for command line arguments.
5. Write a JAVA program to sort given list of numbers.
6. Write a JAVA program to search for an element in a given list of elements (linear search).
7. Write a JAVA program to search for an element in a given list of elements using binary search
mechanism.
8. Write a JAVA program to determine the addition of two matrices.
9. Write a JAVA program to determine multiplication of two matrices.
10. Write a JAVA program to sort an array of strings
11. Write a JAVA program to check whether given string is palindrome or not.
12. Write a JAVA program for the following
- 1. Example for call by value. 2. Example for call by reference.
13. Write a JAVA program to give the example for ‘this’ operator. And also use the‘this’ keyword as
return statement.
14. Write a JAVA program to demonstrate static variables, methods, and blocks.
15. Write a JAVA program to give the example for ‘super’ keyword.
16. Write a JAVA program that illustrates simple inheritance.
17. Write a JAVA program that illustrates multi-level inheritance
18. Write a JAVA program demonstrating the difference between method overloading and method
overriding.
19. Write a JAVA program demonstrating the difference between method overloading and constructor
overloading.
20. Write a JAVA program that describes exception handling mechanism.
21. Write a JAVA program for example of try and catch block. In this check whether the given array size
is negative or not.
22. Write a JAVA program to illustrate sub class exception precedence over base class.
23. Write a JAVA program for creation of user defined exception.
24. Write a JAVA program to illustrate creation of threads using runnable class.(start method start each
of the newly created thread. Inside the run method there is sleep() for suspend the thread for 500
milliseconds).
25. Write a JAVA program to create a class MyThread in this class a constructor, call the base class
constructor, using super and starts the thread. The run method of the class starts after this. It can be
observed that both main thread and created child thread are executed concurrently
26. Write a JAVA program illustrating multiple inheritance using interfaces.
27. Write a JAVA program to create a package named pl, and implement this package in ex1 class.
28. Write a JAVA program to create a package named mypack and import it in circle class.
29. Write a JAVA program to give a simple example for abstract class.
30. Write a JAVA program that describes the life cycle of an applet.
31. Write a JAVA program to create a dialogbox and menu.
32. Write a JAVA program to create a grid layout control.
33. Write a JAVA program to create a border layout control.
34. Write a JAVA program to create a padding layout control.
35. Write a JAVA program to create a simple calculator.
36. Write a JAVA program that displays the x and y position of the cursor movement using Mouse.
37. Write a JAVA program that displays number of characters, lines and words in a text file.

Labels:

II BTECH II SEM JAVA PROGRAMMING SYLLABUS ( R13 )

II BTECH II SEM JAVA PROGRAMMING SYLLABUS(R13)

JAVA PROGRAMMING

Objective: Implementing programs for user interface and application development using core java
principles
UNIT I
Objective: Focus on object oriented concepts and java program structure and its installation
Introduction to OOP,
 Introduction, Need of Object Oriented Programming, Principles of Object Oriented Languages, Procedural languages Vs OOP, Applications of OOP, History of JAVA, Java Virtual Machine, Java Features, Program structures, Installation of JDK1.6

UNIT II
Objective: Comprehension of java programming constructs, control structures in Java
Programming Constructs
Variables , Primitive Datatypes, Identifiers- Naming Coventions, Keywords, Literals, Operators-Binary,Unary and ternary, Expressions, Precedence rules and Associativity, Primitive TypeConversion and Casting, Flow of control-Branching,Conditional, loops.Classes and Objects- classes, Objects, Creating Objects, Methods, constructors-Constructor overloading, cleaning up unused objects-Garbage collector, Class variable and Methods-Static keyword, this keyword, Arrays, Command line arguments
UNIT III
Objective: Implementing Object oriented constructs such as various class hierarchies, interfaces and
exception handling
Inheritance: Types of Inheritance, Deriving classes using extends keyword, Method overloading, super keyword, final keyword, Abstract class Interfaces, Packages and Enumeration: Interface-Extending interface, Interface Vs Abstract classes,
Packages-Creating packages , using Packages, Access protection, java.lang package Exceptions & Assertions - Introduction, Exception handling techniques-try...catch, throw, throws, finally block, user defined exception, Exception Encapsulation and Enrichment, Assertions

UNIT IV
Objective: Understanding of Thread concepts and I/O in Java
MultiThreading : java.lang.Thread, The main Thread, Creation of new threads, Thread priority,
Multithreading- Using isAlive() and join(), Syncronization, suspending and Resuming threads,
Communication between Threads
Input/Output: reading and writing data, java.io package

UNIT V
Objective: Being able to build dynamic user interfaces using applets and Event handling in java
Applets- Applet class, Applet structure, An Example Applet Program, Applet Life Cycle, paint(),update() and repaint()
Event Handling -Introduction, Event Delegation Model, java.awt.event Description,Sources of Events, Event Listeners, Adapter classes, Inner classes.

UNIT VI
Objective: Understanding of various components of Java AWT and Swing and writing code snippets
using them Abstract Window Toolkit
Why AWT?, java.awt package, Components and Containers, Button, Label, Checkbox, Radio buttons, Listboxes, Choice boxes, Text field and Text area, container classes, Layouts, Menu, Scroll bar 
Swing:
Introduction , JFrame, JApplet, JPanel, Components in swings, Layout Managers, JList and JScroll Pane, Split Pane, JTabbedPane, Dialog Box Pluggable Look and Feel

TEXT BOOKS
1. The Complete Refernce Java, 8ed, Herbert Schildt, TMH
2. Programming in JAVA, Sachin Malhotra, Saurabh choudhary, Oxford.
3. JAVA for Beginners, 4e, Joyce Farrell, Ankit R. Bhavsar, Cengage Learning.
4. Object oriented programming with JAVA, Essentials and Applications, Raj Kumar Bhuyya, Selvi, Chu
TMH
5. Introduction to Java rogramming, 7th ed, Y Daniel Liang, Pearson

REFERENCE BOOKS
1. JAVA Programming, K.Rajkumar.Pearson
2. Core JAVA, Black Book, Nageswara Rao, Wiley, Dream Tech
3. Core JAVA for Beginners, Rashmi Kanta Das, Vikas.
4. Object Oriented Programming Through Java, P. Radha Krishna,Universities Press.

Labels:

Tuesday, November 22, 2016

Write a JAVA program to search for an element in a given list of elements (linear search).

Aim: Write a JAVA program to search for an element in a given list of elements (linear search).

Program:

import java.util.Scanner;
 
class LinearSearch 
{
  public static void main(String args[])
  {
    int c, n, search, array[];
 
    Scanner in = new Scanner(System.in);
    System.out.println("Enter number of elements");
    n = in.nextInt(); 
    array = new int[n];
 
    System.out.println("Enter " + n + " integers");
 
    for (c = 0; c < n; c++)
      array[c] = in.nextInt();
 
    System.out.println("Enter value to find");
    search = in.nextInt();
 
    for (c = 0; c < n; c++)
    {
      if (array[c] == search)     /* Searching element is present */
      {
         System.out.println(search + " is present at location " + (c + 1) + ".");
          break;
      }
   }
   if (c == n)  /* Searching element is absent */
      System.out.println(search + " is not present in array.");
  }
}

Output:


Labels:

Write a JAVA program to sort given list of numbers.

Aim: Write a JAVA program to sort given list of numbers.

Program:

import java.util.Scanner;
public class Sort 
{
    public static void main(String[] args) 
    {
        int n, temp;
        Scanner s = new Scanner(System.in);
        System.out.print("Enter no. of elements you want in array:");
        n = s.nextInt();
        int a[] = new int[n];
        System.out.println("Enter all the elements:");
        for (int i = 0; i < n; i++) 
        {
            a[i] = s.nextInt();
        }
        for (int i = 0; i < n; i++) 
        {
            for (int j = i + 1; j < n; j++) 
            {
                if (a[i] > a[j]) 
                {
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }
            }
        }
        System.out.print("Ascending Order:");
        for (int i = 0; i < n - 1; i++) 
        {
            System.out.print(a[i] + ",");
        }
        System.out.print(a[n - 1]);
    }
}

Output:


Labels:

Write a JAVA program give example for command line arguments.

Aim: Write a JAVA program give example for command line arguments.

Program:

class Factorial
{  
public static void main(String args[])  
{    
 int n,i,fact=1; 
 n=Integer.parseInt(args[0]);
if(n==0||n==1)
fact=1;
else
{
 for(i=1;i<=n;i++)
fact*=i; 
}
 System.out.print("factorial("+n+")= "+fact);    
 }
}  

Output:


Labels:

Write a JAVA program to display the Fibonacci sequence

Aim: Write a JAVA program to display the Fibonacci sequence

Program:

class Fibonacci
{  
public static void main(String args[])  
{    
 int n1=0,n2=1,n3,i,count=10;    
 System.out.print(n1+" "+n2);//printing 0 and 1    
    
 for(i=2;i<count;++i)//loop starts from 2 because 0 and 1 are already printed    
 {    
  n3=n1+n2;    
  System.out.print(" "+n3);    
  n1=n2;    
  n2=n3;    
 }    
  
}
}  

Output:


Labels:

Write a JAVA program that displays the roots of a quadratic equation ax2+bx+c=0. Calculate the discriminent D and basing on the value of D, describe the nature of roots.

Aim: Write a JAVA program that displays the roots of a quadratic equation ax2+bx+c=0. Calculate the discriminent D and basing on the value of D, describe the nature of roots.

Program:

import java.util.Scanner;
public class Quadratic_Equation
{
    public static void main(String[] args) 
      {
        int a, b, c;
        double root1, root2, d;
        Scanner s = new Scanner(System.in);
        System.out.println("Given quadratic equation:ax^2 + bx + c");
        System.out.print("Enter a:");
        a = s.nextInt();
        System.out.print("Enter b:");
        b = s.nextInt();
        System.out.print("Enter c:");
        c = s.nextInt();
        System.out.println("Given quadratic equation:"+a+"x^2 + "+b+"x + "+c);
        d = b * b - 4 * a * c;
        if(d > 0)
        {
            System.out.println("Roots are real and unequal");
            root1 = ( - b + Math.sqrt(d))/(2*a);
            root2 = (-b - Math.sqrt(d))/(2*a);
            System.out.println("First root is:"+root1);
            System.out.println("Second root is:"+root2);
        }
        else if(d == 0)
        {
            System.out.println("Roots are real and equal");
            root1 = (-b+Math.sqrt(d))/(2*a);
            System.out.println("Root:"+root1);
        }
        else
        {
            System.out.println("Roots are imaginary");
        }
    }
}

Output:


Labels:

Write a JAVA program to display default value of all primitive data types of JAVA

Aim: Write a JAVA program to display default value of all primitive data types of JAVA

Program:


class  DefaultValues
{
    static byte b;
    static short s;
    static int i;
    static long l;
    static float f;
    static double d;
    static char c;
    static boolean bl;
    public static void main(String[] args) 
    {
        System.out.println("Byte :"+b);
        System.out.println("Short :"+s);
        System.out.println("Int :"+i);
        System.out.println("Long :"+l);
        System.out.println("Float :"+f);
        System.out.println("Double :"+d);
        System.out.println("Char :"+c);
        System.out.println("Boolean :"+bl);
    }
}

Output:


Labels:

Wednesday, November 9, 2016

C Programming Model Question Paper JNTUK (R16)

                                                                       MODEL PAPER
Subject Code: R161107/R16
I B. Tech I Semester Regular Examinations Nov. - 2016
COMPUTER PROGRAMMING
(Common to ECE, AE, AME, BioTech, ChemE, CE, CSE, IT,EIE,EEE,ME,MetalE,MinE,PCE,PE,EComE)
Time: 3 hours Max. Marks: 70
Question Paper Consists of Part-A and Part-B
Answering the question in Part-A is Compulsory,
Four Questions should be answered from Part-B
*****
PART-A
1. (a) Define Assembly language.
(b) Define implicit type casting with example.
(c) Differentiate between for loop and while loop.
(d) Differentiate between call by value and call by reference.
(e) Write program for printing identity matrix on screen.
(f) Write the importance of typedef
(g) Explain about command line arguments.


[7 x 2 =14]
PART-B

2. (a) Differentiate between procedural and object oriented languages.
(b) What are the components of computer? Explain.


[7+7]
3. (a) Explain about the basic data types in c language with example
(b) Write the importance of precedence and associativity? write the table for operator
precedence.
[7+7]
4. (a) Discuss about selection statements with examples.
(b) Write a program to print the following series on the screen
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
[7+7]
5. (a) What is recursion? Differentiate between recursion with iteration.
(b) Write program for finding the GCD among two numbers using recursion.
[7+7]
6. (a) Explain about different string manipulation functions with examples.
(b) Write a program to find given string is palindrome or not.
[7+7]
7. (a) Explain about structure and union with examples.
(b) Write a program to pint file contents on the screen.
[7+7]
*****

Labels:

Tuesday, November 8, 2016

C VIVA QUESTIONS PART 2

C VIVA QUESTIONS PART 2

1. Structure of C Program.


2. Taxonomy of C.




3. Characteristics of C?
  • Small size
  • Extensive use of function calls
  • Loose typing - unlike PASCAL
  • Structured language
  • Low level (BitWise) programming readily available
  • Pointer implementation - extensive use of pointers for memory, array, structures and functions.

4. Applications of C Language?

1. C language is used for creating computer applications
2. Used in writing Embedded softwares
3. Firmware for various electronics, industrial and communications products which use micro-controllers.
4. It is also used in developing verification software, test code, simulators etc. for various applications and hardware products.
5. For Creating Compiles of different Languages which can take input from other language and convert it into lower level machine dependent language.
6. C is used to implement different Operating System Operations.
7. UNIX kernel is completely developed in C Language


5.  Advantages and disadvantages of  C Language.

Advantages of C Language
1. C language is a building block for many other currently known languages. C language has variety of data types and powerful operators. Due to this, programs written in C language are efficient, fast and easy to understand.
2. C is highly portable language. This means that C programs written for one computer can easily run on another computer without any change or by doing a little change.
3. There are only 32 keywords in ANSI C and its strength lies in its built-in functions. Several standard functions are available which can be used for developing programs.
4. Another important advantage of C is its ability to extend itself. A C program is basically a collection of functions that are supported by the C library this makes us easier to add our own functions to C library. Due to the availability of large number of functions, the programming task becomes simple.
5. C language is a structured programming language. This makes user to think of a problem in terms of function modules or blocks. Collection of these modules makes a complete program. This modular structure makes program debugging, testing and maintenance easier.

Disadvantages of C Language

1. C does not have concept of OOPs, that’s why C++ is developed.
2. There is no runtime checking in C language.
3. There is no strict type checking. For example, we can pass an integer value.
4. for the floating data type.
5. C doesn’t have the concept of namespace.
6. C doesn’t have the concept of constructor or destructor.

6. Files used in C Language?

1. Source Files:
Contains Source Program (  .C Extension)
2. Header Files:
A header file is a file with extension .h which contains C function declarations and macro definitions to be shared between several source files. There are two types of header files: the files that the programmer writes and the files that comes with your compiler.
3. Object Files( .o/.obj) :
Object files are generated by the compiler as a result of processing the source code file.
Object files contain compact binary code of function definitions. Linker uses these Object files  to produce an executable file (.exe).
4. Binary Executable files( .exe )
The Binary Executable file is generated by a Linker. The Linker links the various object files to produce binary files that can be directly executed.

7. Compiling and Executing(Running)?

In Linux:

Compiling:
cc program_name.c

Executing:

./a.out

Or


Compiling:
cc –o   object_file_name   program_name.c

Executing:

./object_file_name

 





8. What is a Token?

A Smallest individual Unit in C Program.
·         Keywords
·         Variables
·         Constants
·         Strings
·         Special Characters
·         Operators
9. what  is an Identifier?
Identifier refers to name given to entities such as variables, functions, structures etc.

Rules for writing an identifier

  1. A valid identifier can have letters (both uppercase and lowercase letters), digits and underscores.
  2. The first letter of an identifier should be either a letter or an underscore. However, it is discouraged to start an identifier name with an underscore.
  3. There is no rule on length of an identifier. However, the first 31 characters of identifiers are discriminated by the compiler.
10. Data Types in c?




11. What is Constant?

Constants are identifiers which values do not change.

12. Operators in C?

Operators are the symbols which tell the computer to execute certain mathematical or logical operations.
1.Arithmetic ( +,-,*,/,% )
2. Relational ( <,<=,>,>=,==,!= )
3. Logical ( &&,||,! )
4. Unary Operators  ( -)
5. Increment  /  Decrement  Operators  (  ++ , -- )
6. Conditional   /   Ternary Operator    ( ? : )
7. Bitwise Operators   (  & , | , ^  )
8. Shift Operators  ( <<  ,   >>  )
9. Assignment Operators  ( +=  , -= , *=  ,  /=  ,  %= )
10.Special Operators   ( comma, sizeof )

13. Define Precedence and Associativity?
Precedence :
Operator precedence determines which operator is performed first in an expression with more than one operators with different precedence. For example 10 + 20 * 30 is calculated as 10 + (20 * 30) and not as (10 + 20) * 30.
Associativity:
associativity is used when two operators of same precedence appear in an expression. Associativity can be either Left to Right or Right to Left. For example ‘*’ and ‘/’ have same precedence and their associativity is Leftto Right, so the expression “100 / 10 * 10” is treated as “(100 / 10) * 10”.


Labels: