Earn by twitter on twivert

Sign up for PayPal and start accepting credit card payments instantly.
Showing posts with label pointer. Show all posts
Showing posts with label pointer. Show all posts

Monday, November 1, 2010

WAP function using a pointer to a function


/*WAP Invoking a function using a pointer to a function */
#include<stdio.h>
#include<conio.h>
main( )
{
 int  display( ) ;
 int  ( *func_ptr )( ) ;

 func_ptr = display ;  /* assign address of function */ 
 printf ( "\nAddress of function display is %u", func_ptr ) ;
 ( *func_ptr )( ) ;  /* invokes the function display( ) */
         getch();
}

int  display( )
{
 puts ( "\nLong live viruses!!" ) ;
}

Saturday, September 18, 2010

WAP to Using pointer to access array elements


/*WAP to Using pointer to access array elements */
#include<stdio.h>
#include<conio.h>
main( )
{
 char  name[ ] = "Goldfish" ;
 char  *ptr ;

 ptr = name ;  /* store base address of string */

 while ( *ptr != `\0' )
 {
  printf ( "%c", *ptr ) ;
  ptr++ ;
 }
}

WAP to Usage of pointer to an array


/*WAP to Usage of pointer to an array */
#include<stdio.h>
#include<conio.h>
main( )
{
 int  s[5][2] = {
     { 1234, 56 },
     { 1212, 33 },
     { 1434, 80 },
     { 1312, 78 }
       } ;  
 int  ( *p )[2] ;
 int  i, j, *pint ;
 
 for ( i = 0 ; i <= 3 ; i++ )
 {
   p = &s[i] ;
  pint = p ;
  printf ( "\n" ) ;
  for ( j = 0 ; j <= 1 ; j++ )
   printf ( "%d ", *( pint + j ) ) ; 
 }
}

Thursday, September 16, 2010

WAP to access array elements


/*WAP to access array elements */
#include<stdio.h>
#include<conio.h>
main( )
{
 int  num[ ] = { 24, 34, 12, 44, 56, 17 } ;
 int  i ;

 for ( i = 0 ; i <= 5 ; i++ )
 {
  printf ( "\naddress = %u ", &num[i] ) ;
  printf ( "element = %d", num[i] ) ;
 }
}

WAP to print out the memory locations


/*WAP to print out the memory locations*/
#include<stdio.h>
#include<conio.h>
main( )
{
 int  num[ ] = { 24, 34, 12, 44, 56, 17 } ;
 int  i ;

 for ( i = 0 ; i <= 5 ; i++ )
 {
  printf ( "\nelement no. %d ", i ) ;
  printf ( "address = %u", &num[i] ) ;
 }
}

WAP to Comparison of two pointer variables


/*WAP to Comparison of two pointer variables */
#include<stdio.h>
#include<conio.h>
main( )
{
 int  arr[ ] = { 10, 20, 36, 72, 45, 36 } ;
 int  *j, *k ;

 j = &arr [ 4 ] ;
 k = ( arr + 4 ) ;

 if ( j == k )
  printf ( "The two pointers point to the same location" ) ;
 else
  printf ( "The two pointers do not point to the same location" ) ;
}

WAP to Subtraction of one pointer from another


/*WAP to Subtraction of one pointer from another*/
#include<stdio.h>
#include<conio.h>
main( )
{
 int  arr[ ] = { 10, 20, 30, 45, 67, 56, 74 } ;
 int  *i, *j ;

 i = &arr[1] ;
 j = &arr[5] ;
 printf ( "%d %d", j - i, *j - *i ) ;
}

WAP to Introducing pointers


/*WAP to Introducing pointers */
#include<stdio.h>
#include<conio.h>
main( )
{
 int  i = 3, *x ;
 float  j = 1.5, *y ;
 char  k = 'c', *z ;

 printf ( "\nValue of i = %d", i ) ;
 printf ( "\nValue of j = %f", j ) ;
 printf ( "\nValue of k = %c", k ) ;
 x = &i ;
 y = &j ;
 z = &k ;
 printf ( "\nOriginal address in x = %u", x ) ;
 printf ( "\nOriginal address in y = %u", y ) ;
 printf ( "\nOriginal address in z = %u", z ) ;
 x++ ;
 y++ ;
 z++ ;
 printf ( "\nNew address in x = %u", x ) ;
 printf ( "\nNew address in y = %u", y ) ;
 printf ( "\nNew address in z = %u", z ) ;
}


ADS

How to earn online

How to earn online:
Step - 1 :
signup for PayPal, to recieve your online earning
click here:
https://www.paypal.com/in/mrb/pal=CZ7224TZBMCBL
step - 2 : Singup these 4 sites & earn & enjoy! Read site to know how to earn.
1. trekpay
Earn up to $0.02 (2 cents) per click.
http://www.trekpay.com/?ref=34690
2. neobux
Earn up to $0.02 (2 cents) per click.
Click here:
http://www.neobux.com/?r=Moneyearner786

AddMe

Bookmark and Share