Friday, October 28, 2016

C VIVA QUESTIONS PART 1

1. What is a variable?

Variables are simply names used to refer to some location in memory

a location that holds a value with which we are working.

It may help to think of variables as a placeholder for a value.

2. Define computer?
A computer is an electronic device that manipulates information, or data. It has the ability to store, retrieve, and process data. 

3. Define data?
Data is a collection of facts, such as numbers, words, measurements, observations or even just descriptions of things.

4.Define Information?

Information is organised or classified data which has some meaningful values for the receiver.
Information is the processed data on which decisions and actions ar. based.
5. Define Knowledge?

Knowledge is the application of  data and information.



                                       
6. Define Instruction?

Commands given to the computer that tells what it has to do are instructions.

7. Define Program?
A set of instructions in computer language is called a program.


8. Define Software?
A set of programs is called software


9. Define Hardware?
A computer and all its physical parts are known as hardware.

10. System Software?
System software is a type of computer program that is designed to run a computer's hardware and application programs. 
The operating system (OS) is the best-known example of system software. The OS manages all the other programs in a computer.
Exampls : 
1)MicrosoftWindows 
2)Linux 
3)Unix 
4)Mac OSX 
5)DOS 
6)BIOS Software 
7)HDSectorBoot Software 
8)DeviceDriverSoftware i.e Graphics Driver etc 
9) Linker Software 
10) Assembler and Compiler Software 

11.Define application software?
An application program (app or application for short) is a computer program designed to perform a group of coordinated functions, tasks, or activities for the benefit of the user. Examples of an application include a word processor, a spreadsheet, an accounting application, a web browser, a media player, an aeronautical flight simulator, a console game or a photo editor. The collective nounapplication software refers to all applications collectively. This contrasts with system software, which is mainly involved with running the computer.

12. Define Utility Software?
Utility software is system software designed to help analyze, configure, optimize or maintain a computer.
Examples of utility programs are antivirus software, backup software and disk tools.


13. What is Translator?
translator is a computer program that performs the translation of a program written in a given programming language into a functionally equivalent program in a different computer language, without losing the functional or logical structure of the original code.

14. what is compiler?
A Compiler is a computer program that translates code written in a high level language to a lower level language, object/machine code. 

15. what is interpreter?
An interpreter program executes other programs directly, running through program code and executing it line-by-line. As it analyses every line, an interpreter is slower than running compiled code but it can take less time to interpret program code than to compile and then run it.


16. what is assembler?
An assembler translates assembly language into machine code.



17. what is linker?
In high level languages, some built in header files or libraries are stored. These libraries are predefined and these contain basic functions which are essential for executing the program. These functions are linked to the libraries by a program called Linker. If linker does not find a library of a function then it informs to compiler and then compiler generates an error. The compiler automatically invokes the linker as the last step in compiling a program.

18. what is loader?
 Loader is a program that loads machine codes of a program into the system memory. In Computing, a loader is the part of an Operating System that is responsible for loading programs.

19. what is Debugger?
a computer program that assists in the detection and correction of errors in other computer programs.

20. what are program designing tools?
Algorithm and flowchart
Alogorithm: A sequential solution of any program that written in human language,called algorithm.
Algorithm is first step of the solution process, after the analysis of problem, programmer write the algorithm of that problem.

Flowchart:
Graphical representation of any program is called flowchart.

21. what are generations of Programming languages?
 1. The first generation languages, or 1GL are low-level languages that are machine language.
2. The second-generation languages, or 2GL are also low-level assembly languages.
3. The third-generation languages, or 3GL are high-level languages such as C.
4. The fourth-generation languages, or 4GL are languages that consist of statements similar to statements in a human language. Fourth generation languages are commonly used in database programming and scripts.
5. The fifth-generation languages, or 5GL are programming languages that contain visual tools to help develop a program. A good example of a fifth generation language is Visual Basic.

22. What is Relocatable Code?
Relocatable code is software whose execution address can be changed. A relocatable program might run at address 0 in one instance, and at 10000 in another.


23. What is object code?
code produced by a compiler or assembler.


24. What is object file?
Compilers and assemblers create object files containing the generated binary code and data for a source file. Linkers combine multiple object files into one, loaders take object files and load them into memory.


25. What is Structured programming ?

Structured programming (sometimes known as modular programming) is a subset of procedural programming that enforces a logical structure on the program being written to make it more efficient and easier to understand and modify. Certain languages such as Ada, Pascal, and dBASE are designed with features that encourage or enforce a logical program structure.

26. what is object oriented programming?

Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic. 

Labels:

Thursday, October 20, 2016

C Progarm to convert Decimal to Binary and Hexadecimal using Switch


Aim: Write a C Progarm to convert Decimal to Binary and Hexadecimal using Switch.

Theory:

Binary number system: It is base 2 number system which uses the digits from 0 and 1.Decimal number system:It is base 10 number system which uses the digits from 0 to 9Hexadecimal number system: It is base 16 number system which uses the digits from 0 to 9 and A, B, C, D, E, F.
Following steps describe how to convert decimal to any Base Number SystemStep 1: Divide the original decimal number by desired base(eg: 2 for binary)Step 2: Divide the quotient by baseStep 3: Repeat the step 2 until we get quotient equal to zero.Equivalent Desired base number would be remainders of each step in the reverse order

Program:

#include<stdio.h>
void binary(int);
void hex(int);
main()
{
   int decimalNumber,choice;
   printf("Enter any decimal number: ");
   scanf("%ld",&decimalNumber);
   printf("1-Binary Number\n 2-Hexadecimal Number\n");
   printf("Enter Choice:");
   scanf("%d",&choice);
   switch(choice)
   {
      case 1:binary(decimalNumber);
                 break;
      case  2:hex(decimalNumber);
    break;
      default:printf("Invalid option");
   }
}
void binary(int d)
{
   int remainder,quotient;
   int binaryNumber[100],i=1,j;
   quotient = d;
    while(quotient!=0)
    {
         binaryNumber[i++]= quotient % 2;
         quotient = quotient / 2;
    }
    printf("Equivalent binary value of decimal number %d: ",d);
    for(j = i -1 ;j> 0;j--)
         printf("%d",binaryNumber[j]);
}

void hex(int d)
{
   int remainder,quotient;
   int i=1,j,temp;
   char hexadecimalNumber[100];
    quotient = d;
    while(quotient!=0)
     {
         temp = quotient % 16;
         /*To convert integer into character
             ASCII value of zero is 48
             ASCII value of A is 65   */
         if( temp < 10)
             temp =temp + 48;
         else
             temp = temp + 55;
         hexadecimalNumber[i++]= temp;
             quotient = quotient / 16;
      }

    printf("Equivalent hexadecimal value of decimal number %d: ",d);
    for(j = i -1 ;j> 0;j--)
      printf("%c",hexadecimalNumber[j]);
}


Output:


Labels:

Friday, October 14, 2016

Computer Software

Computer Software

Computer software is divided into two broad categories. One is System software and other one is Application Software.
            System software managers the computer resources it provides the interface between the hardware and the users but does nothing to directly serve the user.

a program in javabean to implement indexed properties of a bean using simplebeaninfo class

Aim: write a program in javabean to implement indexed properties of a bean using simplebeaninfo.

Program:

PieC.java
package sunw.demo.indexed;
import java.awt.*;
import java.io.*;
public class PieC
{
            private double data[ ];
            public double getData(int index)
            {
                        return data[index];
            }
            public void setData(int index, double value)
            {
                        data[index] = value;
            }
            public double[ ] getData( )
            {
                        return data;
            }
            public void setData(double[ ] values)
            {
                        data = new double[values.length];
                        System.arraycopy(values, 0, data, 0, values.length);
            }
}

PieCBeanInfo.java

package sunw.demo.indexed;
import java.beans.*;
public class PieCBeanInfo extends SimpleBeanInfo
{
     public PropertyDescriptor[] getPropertyDescriptors()
       {
           try
               {
                    PropertyDescriptor data= new PropertyDescriptor("data",PieC.class);
                    PropertyDescriptor p[] = {data};
                    return p;
              }
          catch(Exception e)
              {

               }
          return null;
       }
}

Output:



Labels:

a program in java bean to implement indexed properties of a bean

Aim: write a program in javabean to implement indexed properties of a bean.

Program:

package sunw.demo.indexed;
import java.awt.*;
import java.io.*;
public class PieC
{
            private double data[ ];
            public double getData(int index)
            {
                        return data[index];
            }
            public void setData(int index, double value)
            {
                        data[index] = value;
            }
            public double[ ] getData( )
            {
                        return data;
            }
            public void setData(double[ ] values)
            {
                        data = new double[values.length];
                        System.arraycopy(values, 0, data, 0, values.length);
            }
}

Output:


Labels:

a program in javabean to implement simple properties of a bean using simplebeaninfo class

Aim: write a program in javabean to implement simple properties of a bean using simplebeaninfo.


Program:

Box.java
package sunw.demo.Box;
import java.awt.*;
public class Box extends Canvas
{
   private int depth,height,width;
    public Box()
     {
        setSize(120,30);
        height=0;
        depth=0;
        width=0;
}
  public int getDepth()
   {
       return depth;
    }
   public void setDepth(int depth)
    {
       this.depth=depth;
    }
   public int getHeight()
   {
       return height;
    }
   public void setHeight(int height)
   {
       this.height=height;
    }
   public int getWidth()
   {
       return width;
    }
   public void setWidth(int width)
    {
        this.width=width;
    }
    public void paint(Graphics g)
    {
        double volume=(height*depth*width);
        String msg="Volume="+volume;
        g.drawString(msg,10,10);
     }
 }

BoxBeanInfo.Java

package sunw.demo.Box;
import java.beans.*;
public class BoxBeanInfo extends SimpleBeanInfo
{
     public PropertyDescriptor[] getPropertyDescriptors()
       {
           try
               {
                    PropertyDescriptor height = new PropertyDescriptor("height",Box.class);
                    PropertyDescriptor width = new PropertyDescriptor("width",Box.class);
                    PropertyDescriptor depth = new PropertyDescriptor("depth",Box.class);
                    PropertyDescriptor pd[] = {height,width,depth};
                    return pd;
              }
          catch(Exception e)
              {

               }
          return null;
       }
}

Output:



Labels: