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 ~]$