Languages [TCS Placement]: Sample Questions 8 - 9 of 131

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 8

Edit

Describe in Detail

Essay▾

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

Explanation

  • 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. intmain(void)
  4. {
  5.     char ⚹abc ="hellofriends";
  6.     charletter ='x';
  7.     printf("String before strnset:%s", abc);
  8.     strnset(abc, letter, 5);
  9.     printf("String after strnset:%s", abc);
  10.     return0;
  11. }
  • Output:

String before strnset: hellofriends

String after strnset: xxxxxfriends

Question 9

Edit

Describe in Detail

Essay▾

Mention the execution process for managed code.

Explanation

  • 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.

Developed by: