Skip to main content

Pointer Operations in C programming


1)      Address of any variable can be assigned to a pointer variable. E.g.
        p=&a;   q=&b ;
              where p & q are pointer variables and a & b are simple variables.
2)      Content of one Pointer can be assigned to other pointer provided they point to same data type. E.g.
           int *p, *q;
            p=q;
3)      Integer data can added to or subtracted from pointer variables.
        E.g. int *p;
                p+1;
4)      One pointer can be subtracted from other pointer provided they point to elements of same array. E.g.
         int a[3],*pf,*pl;
           pf=a;
           pl=a+2;
      printf(“%p”,pl-pf);
5)      There is no sense in assigning an integer to a pointer variable.
6)      Pointer variable can not be multiplied and added.
7)      Null value can be assigned to a pointer variable.

Passing pointer to a function
       
  Write a program to covert upper case letter into lower and vice versa using call by reference.
void conversion(char *); //function prototypes
void main()
 {
  char input;
  clrscr();
  printf("Enter Character of Ur choice\n");
  scanf("%c",&input);
  conversion(&input);
  printf("\nThe corresponding character is\t%c",input);
  getch();
}

void conversion(char *c)
  {
  if(*c>=97 && *c<=122)
     *c=*c-32;
  else if(*c>=65 && *c<=90)
    *c=*c+32;
  }

Comments

Popular posts from this blog

Difference between Binary mode and Text Mode in C programming

There are mainly three difference between binary and text mode. They are as follow.               i.       In text mode, a special character EOF whose ASCII value is 26 is inserted after the last character in the file to mark the end of file. But, there is no such special character present in the binary mode. The binary mode files keep track of the end of file from the number of characters present in the directory entry of the file.             ii.       In text mode of file, text and numbers are stored as one character per byte. For example, the number 1234 occupies two bytes in memory but it occupies 4 bytes (one byte per character) in the file. But, in binary mode, the number occupies the number of bytes as it occupies in the memory. Thus,  the above number occupies two bytes in file also in the case o...

Types of Functions in C Programming

C program has two types of functions: 1. Library Functions 2. User defined functions Library Functions: These are the functions which are already written, compiled and placed in C Library and they are not required to be written by a programmer. The function’s name, its return type, their argument number and types have been already defined. We can use these functions as required. For example: printf(), scanf(), sqrt(), getch(), etc. User defined Functions: These are the functions which are defined by user at the time of writing a program. The user has choice to choose its name, return type, arguments and their types. The job of each user defined function is as defined by the user. A complex C program can be divided into a number of user defined functions. For example: #inlcude<stdio.h> double convert (int) ; /* function proto type */ main() { int c ; /* double d ; */ printf (“Enter temperature in Celsius: ”) ; scanf (“%d”, &c) ; /* d =...

CPU (Central Processing Unit)

PGA reffered as pin grid array in which pins of CPU are lined up in a straight format. SPGA referred as staggered pin grid array. in which pins of CPU are arranged staggered format. LGA reffered to as Land Grid Array in which pins are available within inside the socket but not in the CPU in other words in line grid array, in CPU ther are no pinsbut insteadpins areattached with in a socket which contact with with the CPU. for e.g. LGA775 socket(no pins on cpu) has better cooling system. better contact and better locking(climbing). LGA1155: Letest generation I socket, also reffered as sandy bridge, Turbo boost overclocking. More resent than LGA 1156 socket. LGA1156: ability to north bridge Doul channel DDR3 optional integreted graphics PCI express LGA1366: hi end core i series socket integreted tiple channal memmory controller external control bridge(HUB) Upgrading CPU: need to check its core suppert check multiprocessor supports or not check on the ...