Friday, August 17, 2012

Pointer In C (In Depth) (Final) Part 4

Generic Pointer in C Programming

Generic pointer:
void pointer in c is known as generic pointer. Literal meaning of generic pointer is a pointer which can point type of data.

Example:

void *ptr;

Here ptr is generic pointer.

Thursday, August 16, 2012

Pointer in C (In Depth) Part 3


Pointer to function in c programming

What will be output if you will execute following code?
int * function();
void main(){
auto int *x;
int *(*ptr)();
ptr=&function;
x=(*ptr)();
printf("%d",*x);
}
int *function(){
static int a=10;
return &a;
}
Output: 10
Explanation: Here function is function whose parameter is void data type and return type is pointer to int data type.
x=(*ptr)()
=> x=(*&functyion)() //ptr=&function
=> x=function() //From rule *&p=p
=> x=&a
So, *x = *&a = a =10


Pointer in C (In Depth) Part 2


Arithmetic Operation with Pointer in C Programming


Rule 1:

Address + Number= Address
Address - Number= Address
Address++ = Address
Address-- = Address
++Address = Address
--Address = Address

Monday, August 13, 2012

Pointer In C (In Depth) Part 1



POINTER

Pointer is a variable just like other variables of c but only difference is unlike the other variable it stores the memory address of any other variables of c. This variable may be type of int, char, array, structure, function or any other pointers. 

For examples:

(1) Pointer p which is storing memory address of a int type variable:
int i=50;
int *p=&i;

(2) Pointer p which is storing memory address of an array:

int arr[20];
int (*p)[20]=&arr;


Thursday, August 9, 2012

String In JAVA

Strings

Definition:

Strings, which are widely used in Java programming, are a sequence of characters. In the Java programming language, strings are objects.

The Java platform provides the String class to create and manipulate strings.


Creating Strings

The most direct way to create a string is to write:


String greeting = "Hello world!";


Garbage Collector in Java


The Garbage Collector in JAVA

Some object-oriented languages require that you keep track of all the objects you create and that you explicitly destroy them when they are no longer needed. Managing memory explicitly is tedious and error-prone. The Java platform allows you to create as many objects as you want (limited, of course, by what your system can handle), and you don't have to worry about destroying them. The Java runtime environment deletes objects when it determines that they are no longer being used. This process is called garbage collection.
 

Wednesday, August 8, 2012

Data Structures Interview Questions and Answers


Data Structures Interview Questions and Answers

Q 1. What is data structure?

Ans.  A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data.

Q 2. List out the areas in which data structures are applied extensively?
Compiler Design, Operating System, Database Management System, Statistical analysis package, Numerical Analysis, Graphics, Artificial Intelligence, Simulation


Tuesday, August 7, 2012

SQL Query Part 2

Query 1.      Case stmt example

 Tables                           Query                                               Result
  EMP_JB
SELECT id
ANSWER
       
,job
===============
  ID JOB
,CASE
ID  JOB
STATUS
          
WHEN  job  =  'Sales'
         
     
10 Sales
THEN  'Fire'
10
Sales
Fire
 20 Clerk
ELSE  'Demote'
20
Clerk
Demote
       
END  AS  STATUS
FROM emp_jb;
Query 2. Fetch  first  "n"  rowsexample

 Tables                           Query                                               Result

EMP_NM
SELECT
*
ANSWER
         
FROM
emp_nm
=========
 ID NAME
ORDER  BY  id  DESC
ID  NAME
            
FETCH  FIRST  2  ROWS  ONLY;
          
 10 Sanders  
50
Hanes
 20 Pernal    
20
Pernal
 50 Hanes
  


SQL Query Part 1

Query 1.      Join example

 Tables                           Query                           Result

Table 1                 Table 2 
EMP_NM
 EMP_JB
SELECT
nm.id
ANSWER
,nm.name
================
ID NAME
  ID JOB
,jb.job
ID  NAME
JOB
FROM
emp_nm  nm
 
10 Sanders
10 Sales 
,emp_jb  jb
10
Sanders
Sales
20 Pernal  
20 Clerk 
WHERE
nm.id  =  jb.id
20
Pernal
Clerk
50 Hanes
ORDER  BY  1;

Query 2.    Leftouterjoin  example

 Tables                           Query                           Result


Table 1                 Table 2 
EMP_NM
  EMP_JB
SELECT
nm.id
ANSWER
,nm.name
================
ID NAME
   ID JOB
,jb.job
ID  NAME
JOB
  
  
FROM
emp_nm  nm
 
10 Sanders 
10 Sales
LEFT  OUTER  JOIN
10
Sanders
Sales
20 Pernal  
20 Clerk
emp_jb  jb
20
Pernal
Clerk
50 Hanes
ON
nm.id  =  jb.id
50
Hanes
ORDER  BY  nm.id;

Monday, August 6, 2012

C Programming Question Part 3

Pattern Print with Unique and Extreme Logic
 Pattern  1. ***
**
*
**
***
 Code: #include <stdio.h>
main()
{


int i,x,j;
for (i=2; i>=-2;i--)
{

x = 1 + 2*abs(i);
for (j=1;j<=x;j++) printf("*");
printf("\n");

}
}
 Pattern 2. RAJVEER
A        E     
J        E
V        V
E        J
E        A
REEVJAR
 Code:  #include<conio.h>
#include<string.h>
void main()
{
     char str[20];
      int i,j,k,len;
      printf("Enter the String: ");
      gets(str);
      len=strlen(str);
      puts(str);
      printf("");
      for(i=1;i<len-1;i++)
      {
            printf("%c",str[i]);
            for(j=0;j<len-2;j++)
                  printf(" ");
            printf("%c\n",str[len-i-1]);
      }
      strrev(str);
      puts(str);
}
Pattern 3. *
 **
   ***
 **
*
Code: #include <stdio.h>
main()
{


int i,x,j;
for (i=2; i>=-2;i--)
{

x = 1 + abs(i);
for (j=1;j<=x;j++) printf(" ");
for (j=1;j<=x;j++) printf("*");
printf("\n");

}
}
Pattern 4. 1
01
101
0101
Code: #include<stdio.h>
#include<conio.h>

void main()
{
  int i,j;
  int count = 1;
  clrscr();
  for(i=1;i<=4;i++)
  {
        for(j=1;j<=i;j++)
        {
            printf("%d",(i+j+1)%2);               
        }
    printf("\n");   
  }
  getch();
}