Saturday, September 21, 2013

Online Compile for "C"


Enter your name:

C-Gods Programming Language

"C Language"

#include <stdio .h>
//SUM OF TWO NUMBERS

main()
{
  
      int a,b,c;
      printf("Enter two numbers to add");
      scanf("%d%d",&amp;a,&amp;b);
      c=a+b;
      printf("Result=",a);
     
  
}

Saturday, September 14, 2013

9-PLANETS-POSITION


Enter your name:

GROWING


Dynamic Positioning

Welcome!

Sunday, September 8, 2013

Windows program-Mouse Event-1(win32)

MOUSE EVENT I

Program:

MouseEvents.C


#include <windows.h>
LRESULT CALLBACK WndProc (HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow )
{
 static  TCHAR szAppName[]=TEXT ("HELLO");
HWND hwnd;
MSG msg;
// DECLARING AND INTIAZING THE WINDOW CLASS
WNDCLASS wc;                                                       // Window class declaration
wc.style = CS_HREDRAW| CS_VREDRAW;        // Window style
wc. lpfnWndProc = WndProc;                                   // Window Procedure
wc.cbClsExtra = 0;                                                     // Extra Parameters
wc.cbWndExtra = 0;                                                   // Extra Parameters
wc.hInstance = hInstance;                                          // Instance handle
wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); // Icon
wc.hCursor = LoadCursor (NULL, IDC_ARROW);            // Window Cursor
wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
                                                                                    // Set Background Color
wc.lpszMenuName = NULL;                                     // Menu Handle
wc.lpszClassName = szAppName;                             // Class Name
// REGISTERING THE WINDOW CLASS
if (!RegisterClass (&wc))
{
            MessageBox(NULL, TEXT("This program requires WindowsNT!"), szAppName, MB_ICONERROR);
            return 0;
}
// CREATING THE WINDOW
hwnd = CreateWindow ( szAppName,                                  // window class name
TEXT("The Hello Program"), // window caption 
WS_OVERLAPPEDWINDOW,      // window style
CW_USEDEFAULT,                                    // initial x position
CW_USEDEFAULT,                                    // initial x position
CW_USEDEFAULT,                                    // initial x position
CW_USEDEFAULT,                                    // initial x position
NULL,                                                            // parent window handle
NULL,                                                            // window menu handle
hInstance,                                          //program instance handle
NULL);                                               // creation parameters
// DISPLAYING THE WINDOW
            ShowWindow (hwnd, iCmdShow);              
            UpdateWindow (hwnd);
// PROCESSING THE MESSAGE LOOP
                                    while (GetMessage(&msg,NULL,0,0))          // extracts message from Message Queue
{
                        TranslateMessage (&msg);
                        DispatchMessage (&msg);                  // dispatches the message received
            }
            return msg.wParam;
}

// WINDOW PROCEDURE FUNCTION
LRESULT CALLBACK WndProc (HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)
{
            char left[]="How are u?";
            char right[]="Hello";
            switch (message)
            {
            case WM_LBUTTONDOWN:           // Left mouse button press message
                        MessageBox(GetFocus(),left,"Left Mouse Button Pressed",MB_OK);
                        return 0;
            case WM_RBUTTONDOWN:          // Right mouse button press message
                        MessageBox(GetFocus(),right,"Right Mouse Button Pressed",MB_OK);
                        return 0;
            case WM_DESTROY:                       // used to close the window
                        PostQuitMessage(0);               // used to terminate while loop in WinMain()
                        return 0;
            }
            return DefWindowProc(hwnd,message,wparam,lparam);

}
Sample Output:

Windows Simple Program-Win32

  1. SIMPLE WINDOW PROGRAM

             PROGRAM:
#include <windows.h>
LRESULT CALLBACK WndProc (HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow )
{
 static  TCHAR szAppName[]=TEXT ("HELLO");
HWND hwnd;
MSG msg;
// DECLARING AND INTIAZING THE WINDOW CLASS
WNDCLASS wc;                                                       // Window class declaration
wc.style = CS_HREDRAW| CS_VREDRAW;        // Window style
wc. lpfnWndProc = WndProc;                                   // Window Procedure
wc.cbClsExtra = 0;                                                     // Extra Parameters
wc.cbWndExtra = 0;                                                   // Extra Parameters
wc.hInstance = hInstance;                                          // Instance handle
wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); // Icon
wc.hCursor = LoadCursor (NULL, IDC_ARROW);            // Window Cursor
wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
                                                                                    // Set Background Color
wc.lpszMenuName = NULL;                                     // Menu Handle
wc.lpszClassName = szAppName;                             // Class Name
// REGISTERING THE WINDOW CLASS
if (!RegisterClass (&wc))
{
            MessageBox(NULL, TEXT("This program requires WindowsNT!"), szAppName, MB_ICONERROR);
            return 0;
}
// CREATING THE WINDOW
hwnd = CreateWindow ( szAppName,   // window class name
TEXT("The Hello Program"), // window caption 
WS_OVERLAPPEDWINDOW,      // window style
CW_USEDEFAULT,          // initial x position
CW_USEDEFAULT,  // initial x position
CW_USEDEFAULT,         // initial x position
CW_USEDEFAULT,              // initial x position
NULL,                         // parent window  handle
NULL,                               // window menu handle
hInstance,                          //program instance handle
NULL);                           // creation parameters
// DISPLAYING THE WINDOW
            ShowWindow (hwnd, iCmdShow);              
            UpdateWindow (hwnd);
// PROCESSING THE MESSAGE LOOP
            while (GetMessage(&msg,NULL,0,0) // extracts message from Message Queue
            {
                                                TranslateMessage (&msg);  // dispatches the message received
                        DispatchMessage (&msg);
            }
            return msg.wParam;
}
// WINDOW PROCEDURE FUNCTION
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
            HDC hdc;
            PAINTSTRUCT ps;
            RECT rect;
            switch (message)
            {
            case WM_PAINT:    // Used to draw on client area using objects
                        hdc = BeginPaint (hwnd, &ps); // Gets Device Context
                        GetClientRect (hwnd, &rect);   // To get Client area size
                        DrawText (hdc, TEXT ("HELLO WINDOWS 98"),-1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
                        EndPaint(hwnd,&ps);    // Releases Device Context
                        return 0;

            case WM_DESTROY:     // Used to close the window
                        PostQuitMessage(0);  // used to terminate while loop in WinMain()
                        return 0;
            }
            return DefWindowProc (hwnd, message, wparam, lparam);
}



Sample Output:




Saturday, September 7, 2013

LINUX OPERATING SYSTEM


LINUX DIRECTORIES

bin , boot,  dev,  etc,  home , lib,  lib64,  lost+found,  media , misc,  mnt,  net,  opt , proc,  root,  sbin,  selinux,  srv,  sys,  tftpboot,  tmp , usr,  var

Some Useful Commands in Linux:
chmod

[mamce@localhost ~]$ ls -l|grep Desktop
drwxr-xr-x 3 mamce mamce   4096 Sep  5 18:42 Desktop
[mamce@localhost ~]$ chmod g+r Desktop
[mamce@localhost ~]$ ls -l|grep Desktop
drwxr-xr-x 3 mamce mamce   4096 Sep  5 18:42 Desktop
[mamce@localhost ~]$ chmod g+w Desktop
[mamce@localhost ~]$ ls -l|grep Desktop
drwxrwxr-x 3 mamce mamce   4096 Sep  5 18:42 Desktop
[mamce@localhost ~]$ chmod o+w Desktop
[mamce@localhost ~]$ ls -l|grep Desktop
drwxrwxrwx 3 mamce mamce   4096 Sep  5 18:42 Desktop
[mamce@localhost ~]$ chmod o+w Desktop
[mamce@localhost ~]$ ls -l|grep Desktop
drwxrwxrwx 3 mamce mamce   4096 Sep  5 18:42 Desktop
[mamce@localhost ~]$ chmod o-w Desktop
[mamce@localhost ~]$ ls -l|grep Desktop
drwxrwxr-x 3 mamce mamce   4096 Sep  5 18:42 Desktop
[mamce@localhost ~]$

Thursday, August 22, 2013

Login page

Login page

Ragava Login page

Username
Password

Monday, July 15, 2013

DBMS-TRIGGERS

                                    TRIGGERS



 AIM:

To perform High-level language extension with triggers (Student mark list).

SYNTAX:

CREATE[OR REPLACE]TRIGGER[schema.]trigger
{BEFORE|AFTER|INSTEAD OF}
{DELETE
|INSERT
|UPDATE[OF column[,column].....]}
|OR {DELETE
|INSERT
|UPDATE[OF column,[,column]....]}]...
ON[schema.]{table|view}
REFERENCING(OLD[AS]old
|NEW[AS]new...]
FOR EACH{ROW|STATEMENT}{WHEN(condition)}]

DESCRIPTION:

            The details about the students mark are being in the stu table with attributes.

            Name
            Rollno
            Mark1
            Mark2
            Mark3

The stu1 table consists of attributes,

            Rollno
            Total
            Average
            Result

The details of the first table are being given in the prompt by the user.  The total, average are processed for currently processed row in the stu table using after insert on trigger the values are placed in the table stu1.

PROGRAM:
create or replace trigger st_trig
after insert on stu
for each row
 declare
 total number;
 average number;
 result varchar2(10);
 begin
 total:=(:new.m1+:new.m2+:new.m3);
 average:=total/3;
 if(:new.m1>50 and :new.m2>50 and :new.m3>50) then
 result:='pass';
 else
result:='fail';
 end if;
 insert into stu1 values(:new.rollno,total,average,result);
 end;

SQL> /

Trigger created.

SQL> desc stu;

 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 NAME                                                 VARCHAR2(20)
 ROLLNO                                             NUMBER
 M1                                                        NUMBER
 M2                                                        NUMBER
 M3                                                        NUMBER

SQL> desc stu1;

 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ROLLNO                                              NUMBER
 TOTAL                                                 NUMBER
 AVERAGE                                           NUMBER
 RESULT                                               VARCHAR2(10)


SAMPLE OUTPUT:

BEFORE TRIGGER CREATION:

SQL> select * from stu;

no rows selected

SQL> select * from stu1;

no rows selected

AFTER TRIGGER CREATION:

SQL> insert into stu values('&name',&rollno,&m1,&m2,&m3);
Enter value for name: GOWTHAM
Enter value for rollno: 1212
Enter value for m1: 100
Enter value for m2: 89
Enter value for m3: 90
old   1: insert into stu values('&name',&rollno,&m1,&m2,&m3)
new   1: insert into stu values('GOWTHAM',1212,100,89,90)

1 row created.

SQL> select * from stu;

NAME                     ROLLNO         M1         M2         M3
-------------------- ---------- ---------- ----------------- ----------
GOWTHAM               1212             100         89         90
GOKILA                     1213               89         67         55
RAMYA                     1214               45         67         78

SQL> select * from stu1;

    ROLLNO      TOTAL    AVERAGE RESULT
     ----------      ---------- ------------------- ----------
      1212             279             139.5           pass
      1213             211             105.5           pass
      1214             190               95               fail





RESULT:

Thus the high-level language extension with triggers has been performed for generating the students mark list.


DBMS-FUNCTIONS and PROCEDURES

EX.NO:5                                FUNCTIONS AND PROCEDURE

AIM:

            To write PL/SQL(Functions)and to understand stored procedures in SQL.

FUNCTION:


            A function is a subprogram that computes a value. The syntax for creating a function is given below

Create or replace function<function_name>[argument]
Return datatype is
(local declaration)
begin
            (executable statements)
[Exception]
            (exception handlers)
end

PROCEDURE:

CREATE [ORREPLACE] PROCEDURE PROCEDURENAME
                        [PARAMETER[IN/OUT/IN/IN OUT] DATATYPE
                        [:=/DEFAULT EXPRESSION]
                        [(PARAMETER)]
                        IS/AS
                        DECLARATION
                        BEGIN
                        PL/SQL CODES
                        [EXCEPTION]
                        END

Sample Output

           *****FUCTION USING FOR STATEMENT*****

  SQL>create  or replace function fact(a number)return number as
  2  i number;
  3  f number;
  4  begin
  5  f:=1;
  6  for i in 1..a
  7  loop
  8  f:=f*i;
  9  end loop;
 10  return f;
 11* end fact;
SQL> /

Function created.

*********FUNCTION USING WHILE STATEMENT *************

SQL> create or replace function fact(a number) return number as
  2   i number;
  3   f number;
  4   begin
  5   f:=1;
  6   i:=1;
  7   while (i<=a)
  8   loop
  9   f:=f*i;
 10   i:=i+1;
 11   end loop;
 12   return f;
 13*  end fact;
 14  /

Function created.

SQL>begin
  2  dbms_output.put_line('the factorial='||fact(&a));
  3* end;
SQL> /
Enter value for a: 4
old   2: dbms_output.put_line('the factorial='||fact(&a))
new   2: dbms_output.put_line('the factorial='||fact(4));
the factorial=24

PL/SQL procedure successfully completed.

*****PROCEDURE TO FIND WHETHER A GIVEN NUMBER IS ODD OR EVEN*********

SQL> declare
  2  n number;
  3  begin
  4  n:=&n;
  5  if(mod(n,2)=0)then
  6  dbms_output.put_line(n||'is even');
  7  else
  8  dbms_output.put_line(n||'is odd');
  9  end if;
 10  end;
 11  /

Enter value for n: 3
old   4: n:=&n;
new   4: n:=3;
3is odd

PL/SQL procedure successfully completed.


**********PROCEDURE TO DISPLAY 1-10 USING WHILE*******
  1   declare
  2   n number;
  3   i number;
  4   begin
  5   n:=10;
  6   i:=1;
  7   while (i<=n)
  8   loop
  9   dbms_output.put_line(i);
 10   i:=i+1;
 11   end loop;
 12*  end;
SQL> /
1
2
3
4
5
6
7
8
9
10

PL/SQL procedure successfully completed.
***********Procedure to display some numbers lesser than given number**********
  1  declare
  2  num number;
  3  i number;
  4  begin
  5  num:=&num;
  6  i:=1;
  7  loop
  8  dbms_output.put_line(i);
  9  exit when(i>num);
 10  i:=i+1;
 11  end loop;
 12* end;
SQL> /
Enter value for num: 4
old   5: num:=&num;
new   5: num:=4;
1
2
3
4
5
PL/SQL procedure successfully completed.


RESULT: Thus the functions and stored procedures are executed in SQL.

DBMS-VIEWS

EX.NO:4                                                VIEWS


AIM:

To study and create View commands

VIEWS:

In SQL, a view is a virtual table based on the result-set of an SQL statement.A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database.

SQL CREATE VIEW Statement

In SQL, a view is a virtual table based on the result-set of an SQL statement.
A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database.

SQL CREATE VIEW Syntax


CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition

SQL Updating a View

You can update a view by using the following syntax:

SQL CREATE OR REPLACE VIEW Syntax

CREATE OR REPLACE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition

SQL Dropping a View

You can delete a view with the DROP VIEW command.

SQL DROP VIEW Syntax

DROP VIEW view_name

                                                      ************
                                                              VIEWS
                                                       ************

                      TABLE 1 CREATION
                      ***************
                     

`                    SQL> create table aa(name varchar2(20),book number(10),edition number(20),price number(20),
         ISBN number(20));

                      Table created.

                      SQL> insert into aa values('&name',&number,&edition,&price,&ISBN);
                      Enter value for name: bb
                      Enter value for number: 23
                      Enter value for edition: 2001
                      Enter value for price: 12
                      Enter value for isbn: 23435
                      old   1: insert into aa values('&name',&number,&edition,&price,&ISBN)
                      new   1: insert into aa values('bb',23,2001,12,23435)

                      1 row created.

                      SQL> /
                      Enter value for name: cc
                      Enter value for number: 55
                      Enter value for edition: 342
                      Enter value for price: 76
                      Enter value for isbn: 687478
                      old   1: insert into aa values('&name',&number,&edition,&price,&ISBN)
                      new   1: insert into aa values('cc',55,342,76,687478)

                      1 row created.

                      SQL> /
                      Enter value for name: dd
                      Enter value for number: 2
                      Enter value for edition: 1233
                      Enter value for price: 123
                      Enter value for isbn: 53616578
                      old   1: insert into aa values('&name',&number,&edition,&price,&ISBN)
                      new   1: insert into aa values('dd',2,1233,123,53616578)

                      1 row created.

                      SQL> /
                      Enter value for name: ee
                      Enter value for number: 21
                      Enter value for edition: 1111
                      Enter value for price: 111
                      Enter value for isbn: 12435798
                      old   1: insert into aa values('&name',&number,&edition,&price,&ISBN)
                      new   1: insert into aa values('ee',21,1111,111,12435798)

                      1 row created.

                      TABLE 2 CREATION
                      *****************
                      SQL> create table qq(name varchar2(20),book number(10),author varchar(20),publisher varchar2(20),
                      ISBN number(20));

                      Table created.

                      SQL> select * from aa;

                      NAME                       BOOK    EDITION      PRICE       ISBN
                      -------------------- ---------- ---------- ---------- ----------
                      bb                           23       2001         12      23435
                      cc                           55        342         76     687478
                      dd                            2       1233        123   53616578
                      ee                           21       1111        111   12435798


                      SQL> insert into qq values('&name','&author',&number,'&publisher',&ISBN);
                      Enter value for name: bb
                      Enter value for author: 21
                      Enter value for number: 23
                      Enter value for publisher: dfd
                      Enter value for isbn: 573568
                      old   1: insert into qq values('&name','&author',&number,'&publisher',&ISBN)
                      new   1: insert into qq values('bb','21',23,'dfd',573568)

                      1 row created.


                      SQL> /
                      Enter value for name: cc
                      Enter value for author: 43
                      Enter value for number: 55
                      Enter value for publisher: fg
                      Enter value for isbn: 65839
                      old   1: insert into qq values('&name','&author',&number,'&publisher',&ISBN)
                      new   1: insert into qq values('cc','43',55,'fg',65839)

                      1 row created.

                      SQL> /
                      Enter value for name: ee
                      Enter value for author: 44
                      Enter value for number: 21
                      Enter value for publisher: dfd
                      Enter value for isbn: 1235798
                      old   1: insert into qq values('&name','&author',&number,'&publisher',&ISBN)
                      new   1: insert into qq values('ee','44',21,'dfd',1235798)

                      1 row created.

                      SQL> /
                      Enter value for name: oo
                      Enter value for author: 87
                      Enter value for number: 34
                      Enter value for publisher: gfh
                      Enter value for isbn: 6358379
                      old   1: insert into qq values('&name','&author',&number,'&publisher',&ISBN)
                      new   1: insert into qq values('oo','87',34,'gfh',6358379)

                      1 row created.

                      SQL> select * from qq;

                      NAME                 BOOK    AUTHOR           PUBLISHER
                      -------------------- ---------- -------------------- --------------------          ISBN
                      ----------
                      bb                           21 23                   dfd
                          573568

                      cc                           43 55                   fg
                          65839

                      ee                           44 21                   dfd
                        1235798


                      NAME                 BOOK     AUTHOR        PUBLISHER     ISBN
                      -------------------- ---------- -------------------- --------------------        ----------
                      oo                           87 34                   gfh            6358379


                     
                      CREATE VIEW STATEMENT
                      **********************
                      SQL>create view ww as select book,name,publisher from qq where ISBN=573568

                      View created.

                      SQL> select * from ww;

                           BOOK NAME                 PUBLISHER
-                    --------- -------------------- --------------------
        21 bb                   dfd

                     
                      UPDETE VIEW STATEMENT
                      **********************


                      SQL> update ww set publisher='qwa'where book=21;
                     
                     
                      1 row updated.

                      SQL> select * from ww;

                      BOOK NAME                 PUBLISHER
                      ---------- -------------------- --------------------
          21 bb                   qwa

                      SQL> create view wq as select name,ISBN,publisher from qq where book>21


                      View created.

                      SQL> select * from wq;

                      NAME                       ISBN PUBLISHER
                      -------------------- ---------- --------------------
                      cc                        65839 fg
                      ee                      1235798 dfd
                      oo                      6358379 gfh

                      SQL> create view ss as select name,book from aa union select name,book from qq;

                      View created.

                      SQL> select * from ss;

                      NAME                       BOOK
                      -------------------- ----------
                      bb                           21
                      bb                           23
                      cc                           43
                      cc                           55
                      dd                            2
                      ee                           21
                      ee                           44
                      oo                           87

                      8 rows selected.

                      COMPLEX VIEW
                      *************

                      SQL> create view er as select author,name,ISBN from qq where book>43;

                      View created.

                      SQL> select * from er;

                      AUTHOR               NAME                       ISBN
                      -------------------- -------------------- ----------
                      21                   ee                      1235798
                      34                   oo                      6358379

                      SQL>select name from(select * from qq where publisher='fg')where ISBN=65839;


                      NAME
                      --------------------
                      Cc

DROP VIEW
*************
SQL> drop view er;

View dropped
                     
Result
           

            Thus the view creation  commands are executed successfully.