Thursday, 13 June 2013

SIMPLE COBOL PROGRAM TO FIND OUT THE STUDENT TOTAL AND GRADES

     
/*COBOL  PROGRAM TO FIND OUT STUDENT GRADES. */

       IDENTIFICATION DIVISION.
       PROGRAM-ID STUDENTGRADE.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
           77 M1 PIC 9(2).
           77 M2 PIC 9(2).
           77 M3 PIC 9(2).
           77 TOTAL PIC 9(4).
       88 FIRST1 VALUE 180 THRU 300.
       88 SECOND VALUE 150 THRU 179.
       88 THIRD VALUE 120 THRU 149.
       88 FAIL VALUE 0 THRU 119.
       PROCEDURE DIVISION.
       PARA.
           DISPLAY 'ENTER STUDENTMARKS'.
           ACCEPT M1.
           ACCEPT M2.
           ACCEPT M3.
           COMPUTE TOTAL = M1 + M2 + M3.
           DISPLAY TOTAL.
           IF FIRST1
           DISPLAY 'A GRADE'
           ELSE
           IF SECOND
           DISPLAY 'B GRADE'
           ELSE
           IF THIRD
           DISPLAY 'C GRADE'
           ELSE
           DISPLAY 'FAIL'
           STOP RUN.  



OUTPUT:


ENTER STUDENT MARKS
45
55
65
0165
B GRADE

Tuesday, 23 April 2013

SIMPLE JAVA PROGRAM FO ADDITION OF TWO NUMBERS USING 3 VARIABLES

SIMPLE JAVA PROGRAM FO ADDITION OF TWO NUMBERS
 USING 3 VARIABLES

import java.lang.*;
class add
{
public static void main(String args[])
{
int a=10,b=20,temp;// HERE A,B,TEMP IS VARIABLES
temp=a+b;//TEMP VARIABLE STORES ADDITION OF A,B
System.out.println("temp="+temp);
}
}



OUT PUT:-
temp=30

Monday, 15 April 2013

Difference between compiler and interpreter


Compiler
A compiler is a piece of code that translates the high level language into machine language. When a user writes a code in a high level language such as Java and wants it to execute, a specific compiler which is designed for Java is used before it will be executed. The compiler scans the entire program first and then translates it into machine code which will be executed by the computer processor and the corresponding tasks will be performed.  

Shown in the figure is basic outline of the compilation process, here program written in higher level language is known as source program and the converted one is called object program. 

Interpreter
Interpreters are not much different than compilers. They also convert the high level language into machine readable binary equivalents. Each time when an interpreter gets a high level language code to be executed, it converts the code into an intermediate code before converting it into the machine code. Each part of the code is interpreted and then execute separately in a sequence and an error is found in a part of the code it will stop the interpretation of the code without translating the next set of the codes.  

The differences between compiler and interpreter are :-

Sunday, 31 March 2013

string search


#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char s[30],t[20];
char*found;
clrscr();
puts("enter the first string");
gets(s);
puts("enter the string to be sacrhed");
gets(t);
found=strstr(s,t);
if(found)
printf("secound string is found to be first string %d",found-s);
else
printf("-1");
getch();
}