TCS Papers: Sample Questions 190 - 191 of 502

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 190

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

Which function sets first n characters of a string to a given character?


  • strnset () function sets portion of characters in a string to given character

  • syntax for strnset () function is given below.

char * strnset (char * string, int c);

  • strnset () function is not standard function which may not available in standard library in C.

  • Example:

  1. #include <stdio.h>
  2. #include <string.h>
  3. int main(void)
  4. {
  5.     char *abc = "hellofriends";
  6.     char letter = 'x';
  7.     printf("String before strnset: %s "abc);
  8.     strnset(abcletter5);
  9.     printf("String after strnset: %s "abc);
  10.     return 0;
  11. }
  • Output:

String before strnset: hellofriends

String after strnset: xxxxxfriends

Question number: 191

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

Mention the execution process for managed code.


  • A piece of managed code is executed as follows:

  • Choosing a language compiler:

    • One or more language compilers target the runtime and provide benefits of CLR.

    • Compiling the code to MSIL:

    • Compiling translates source code into Microsoft intermediate language (MSIL) and generates the required metadata.

    • Compiling MSIL to native code:

    • At execution time, just-in-time (JIT) compiler translates the MSIL into native code.

    • During compilation, code passes a verification process that examines the MSIL and metadata to find out whether the code is type safe.

    • Executing the code:

  • Common language runtime provides the infrastructure for execution.