Looking for a Tutor Near You?

Post Learning Requirement »
x

Choose Country Code

x

Direction

x

Ask a Question

x

x
x
x
Hire a Tutor

C Language

Loading...

Published in: C / C++
765 Views

Simplified Concepts And Implementation of C.

Suman / Gurgaon

6 years of teaching experience

Qualification: B.Tech

Teaches: Computer, IT, C / C++, Java And J2EE, Python Programming, MCA Subjects, Networking, Software Testing, Unix/Linux

Contact this Tutor
  1. libm . a libm . so libc.a libc . so libpthreads . a libpthreads . so Arrays Homogenius collection of items. int A [10] Alloxcates sizeof(int) 10 cc printf("sizeof A -1m -Ipthreads is %d",sizeof(A)); ERROR execution error AL-I] char Name[l@] printf("sizeof Name is %d", sizeof(Name)); short printf("sizeof B is %d", sizeof(B)); int A [10] for (int i
  2. // ERROR for (int i - B[i] = Ali]; Better method: memcpy(B, A, sizeof (A) ) ; // ERROR memcpy(B, A, sizeof (A) ) ; memset (B, print print memset (B, print Rarely Used: memset (B, 1, sizeof(B)); . BC 10] sizeof(int) sizeof(B) 4 int A [10] for (int i
  3. printf("%f" scalar Ali] scalar product of vectors: for (int i++) res Ali] Incomplete array declarations: int AL]; Prototypes : ERROR int function (int AL]); With extern key allowed: extern int AL] • can be completed with initializer list : int { int { sizeof sizeof (A)/sizeof ) // not an incomplete array as count is 10 Number of elements. Number of elements. Better method can be defined as a macro Variable length Arrays: C99 Local Arrays and not gloabls: int I; f (int a) int int A[a+i] int i int Ali] // Varaible length arrays can't be globals! ! // compilation errors f (int a ) int Ala] // can't Initialize variable length arrays Can not jump beyond a Vla in a block, since the definition of a Vla involves an expression with varaibles, possibly just modified prior to the definition, and if the definition is by passed by a jump, array will be un allocated. Jumping into area above Vla definition destroys it, if it was defined previously . int f (void) { return i +20; } int main(int argc, char argv[])
  4. int 1=20; scanf( "%d" , ) ; //ERROR goto AFTER; int AFTER: return @ ; char A[x]; gets(A); x: j 20 i c99 initialization: int A [10] int int int int bounds. ERROR int { bounds. ERROR int AL] {20, 30, 110} 20, 30, 40, 20, 30, 40, 870}; 34, 56, 78 89 } ; // Un-usual that a c compiler checks for array // Un-usual that a c compiler checks for array 34, 56, 78 89 ; int i,j,k,l; int { What will the values of i and j be? Point 19 of cstd 6.7.8 says last values for All] and A[2] will persist. The foot note 130 says ++i and j++ MIGHT not be evaluated as a consequence Two dimensional arrays: int AL 3] Array array array
  5. array sizeof(A[1]) sizeof(A[2]) sizeof (A) [3] [3] [3] int int int int int int AL 3] for (int i - A [2]-----1 array- -4 5, 6, 7, 8, 9, 10, 12, 13, 14, 15 4 array size(int) size(int) size(int) 48 10, 20, 30} 4 -- -16 -- -16 -- -16 7, 8, 9, 10, 12, 13, 14, 15 for (int j scanf ("%d", Implement matrix addition for a 3*4 matrix Implement matrix multiplication for a 3* 2 AND 2 *4 matrix Strings: String is a array of chars that has null termination. char { 'a' 'b' with %s 'd'} c' array of chars Can't use strcpy, strcmp and strlen on C
  6. char char CHI [20] char char char char sizeof(C) str1en(C) sizeof( "abc") scanf ( " , 'b' 'b' 'b' 'b' 10 3 4 c' c'} c' c'} string string string string " abcdef " "hello" ; "world" "abcdefghij kl"); char *cp= strcpy(CH1, strcpy(cp, main() { char char "abcd"); //ERROR Cprogramming' Cprogramming" strcpy(CH2, "abcdefghij kl " ) ; char *cp char *CPI " helloworld" ; "world" char world" char c; gets(CH); gets( cp); gets(&c); scanf( "%s", scanf ( "%c scanf( "%c", scanf ( "%s aENTER ok still gets is dangerous Error techinally may be correct, pratically useless and dangerous techinally may be correct, pratically useless and dangerous CFI); CIA); ok ok still %s without limits is dangerous printf( "%s" , CH); printf("%c' char cp; gets( cp); gets( CPI); char CPI char world" display each of teh characters of CH array one per line. CH+i
  7. CH hello world'\@' char names[5] [20] • for (int i
  8. char ret ptr ret ptr= ret ptr= strchr(cp, strchr(ret strchr(ret ptr+l, ptr+l,
  9. int A [5] {20, 30, 40} int B [10] memcpy(B+1, A, sizeof (A) ) ; memcpy(B+5, A, sizeof (A) ) ; int ip ip + 1 // Next int address ip ip ip+=3; A=A+5 1; ERROR ERROR ERROR ERROR
  10. N/A