Verbal questions 2

1. (a) cheerleaders : pompoms (b) audience:seats (c) team:goalposts (d) conductor:podium (e) referee:decision Ans. (a) 2. archipelago:islands:: (a) arbor:bower (b) garden:flower (c) mountain:valley (d) sand:dune (e) constellation:star Ans. (a) 3. crow:boastful :: (a) smirk:witty (b) conceal:s;y (c) pout:sulky (d) blush:coarse (e) bluster:unhappy Ans. (a) 4. bracket:shelf :: (a) hammer:anvil (b) girder:rivet (c) strut:rafter (d) valve:pipe (e) bucket:well Ans. (a) 5. taxonomy:classification :: (a) etymology:derivation (b) autonomy: authorization (c) economy:rationalization (d) tautology:justification [Read More]

Verbal questions - mixture of words

1. Depreciation: deflation, depression, devaluation, fall, slump 2. Deprecate : feel and express disapproval, 3. Incentive : thing one encourages one to do (stimulus) 4. Echelon : level of authority or responsibility 5. Innovation : make changes or introduce new things 6. Intermittent : externally stopping and then starting 7. Detrimental: harmful 8. Conciliation : make less angry or more friendly 9. Orthodox: conventional or traditional, superstitious 10. Fallible : liable to error [Read More]

File Handling in c

/* Program to create a file and write some data the file */ #include #include main( ) { FILE *fp; char stuff[25]; int index; fp = fopen(“TENLINES.TXT”,“w”); /* open for writing */ strcpy(stuff,“This is an example line."); for (index = 1; index <= 10; index++) fprintf(fp,"%s Line number %d\n”, stuff, index); fclose(fp); /* close the file before ending program */ } FILE * fopen(char * filename, char * mode) The mode value in the above example is set to ‘r’, indicating that we want to read from the file. [Read More]

Random number generation

Understanding how random number generation (RNG) works In java, lets say you wants to generate random number between i to j e.g. [ i,j ) excluding upper limit. One standard pattern for accomplishing this is: Min + (int)(Math.random() \* ((Max - Min) + 1)) The java Math library function Math.random() generates a double value in the range [0,1). Notice this range does not include the 1. In order to get a specific range of values first you need to multiply by the magnitude of the range of values you want covered. [Read More]

General Utilities

These all involve the use of the header , which declares a number of types and macros and several functions of general use. The types and macros are as follows: size_t Described at the start of this chapter. div_t This is the type of the structure returned by div. ldiv_t This is the type of the structure returned by ldiv. NULL Again, described at the start of this chapter. EXIT_FAILURE [Read More]

Error handling

The standard I/O functions maintain two indicators with each open stream to show the end-of-file and error status of the stream. These can be interrogated and set by the following functions: #include void clearerr(FILE *stream); int feof(FILE *stream); int ferror(FILE *stream); void perror(const char *s); Clearerr clears the error and EOF indicators for the stream. Feof returns non-zero if the stream’s EOF indicator is set, zero otherwise. Ferror returns non-zero if the stream’s error indicator is set, zero otherwise. [Read More]

Random access functions

The file I/O routines all work in the same way; unless the user takes explicit steps to change the file position indicator, files will be read and written sequentially. A read followed by a write followed by a read (if the file was opened in a mode to permit that) will cause the second read to start immediately following the end of the data just written. (Remember that stdio insists on the user inserting a buffer-flushing operation between each element of a read-write-read cycle. [Read More]

File handling in cpp

File I/O with Streams: Many real-life problems handle large volumes of data, therefore we need to use some devices such as floppy disk or hard disk to store the data. The data is stored in these devices using the concept of files. A file is a collection of related data stored in a particular area on the disk. Programs can be designed to perform the read and write operations on these files. [Read More]

Using pointers to break into bytes

Eg.1 main() { int i = 257; int *iPtr = &i; printf("%d %d”, *((char*)iPtr), *((char*)iPtr+1) ); } Answer: 1 1 Explanation: The integer value 257 is stored in the memory as, 00000001 00000001, so the individual bytes are taken by casting it to char * and get printed. Eg. 2 main() { int i = 258; int *iPtr = &i; printf("%d %d”, *((char*)iPtr), *((char*)iPtr+1) ); } Answer: 2 1 Explanation: [Read More]

#ifdef & #endif

#ifdef something int some=0; #endif main() { int thing = 0; printf("%d %d\n”, some ,thing); } Answer: Compiler error : undefined symbol some Explanation: This is a very simple example for conditional compilation. The name something is not already known to the compiler making the declaration int some = 0; effectively removed from the source code.  #if something == 0 int some=0; #endif main() { int thing = 0; [Read More]