c notes

2
 1. scanf("%d",&n) // use of & in scanf 2. call by reference: a.sum(int *x,int *y) b. sum(&a,&b) ; 3. pointer arithmeti c: a. dier ence of point ers: b. possibe ony if bot! t!e poin ters point to t! e eements of same array i. in t * #&a$ 1 ; ii. int * #&a$' ; iii. scanf ("%d" , ); // o/p is # inte +ers apart . omparison of t-o pointer a riabes a. ointer ariabes can be c ompare d proided bot! ariabes point to obects of t!e same data type '. 0o o-in+ operations on pointers -i not -or: 1. ddition of t-o pointe rs 2. 3utipication of a pointer -it! a constant 4. 5iision of a pointer -it! a constant 6. ccessin+ ar ray eements by pointers is always faster t!an accessin+ t!em by subscripts 7. Passing an Entire Array to a Function a. main( ) 8 b. int num$ # 8 2, 4, 1 2, , '6, 17 9 ; c. dispa y ( &nu m$, 6 ) ; d.9 e. disp ay ( int *, i nt n ) 8 i. int i ;

Upload: dheeraj-kumar

Post on 05-Nov-2015

212 views

Category:

Documents


0 download

DESCRIPTION

about c programming language

TRANSCRIPT

1. scanf("%d",&n) // use of & in scanf

2. call by reference: a. sum(int *x,int *y)b. sum(&a,&b);

3. pointer arithmetic:a. difference of pointers:b. possible only if both the pointers point to the elements of same arrayi. int *j=&a[1];ii. int *k=&a[5];iii. scanf("%d",k-j); // o/p is 4 => 4 integers apart

4. Comparison of two pointer variablesa. Pointer variables can be compared provided both variables point to objects of the same data type

5. Following operations on pointers will not work:1. Addition of two pointers2. Multiplication of a pointer with a constant3. Division of a pointer with a constant6. Accessing array elements by pointers is always faster than accessing them by subscripts7. Passing an Entire Array to a Functiona. main( ) { b. int num[ ] = { 24, 34, 12, 44, 56, 17 } ;c. dislpay ( &num[0], 6 ) ; d. } e. display ( int *j, int n ) {i. int i ; f. for ( i = 0 ; i