Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 59 - 61 of 354

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 59

Write in Short Short Answer▾

Name some pure object oriented languages.

Edit

Explanation

  • Smalltalk
  • Java
  • Eiffel
  • Sather

Question 60

Describe in Detail Essay▾

What is the output of the following program?

  1. main ()
  2. {
  3. int i =_l_abc (10);
  4. printf ( “%d” --i);
  5. }
  6. int _l_abc (int i)
  7. {
  8. return (i ++ );
  9. }
Edit

Explanation

In the program

Table Shows the Program
int _l_abc (int i)

{

return (i ++) ;

}

  • Return (i ++) will first return i and then increment
  • Therefore, 10 will be returned.
int i = _l_abc (10) ;Here int _l_abc (int i) is a function and int i = 10 defined.
printf ( “% d” -i) ;Print the value if --i is i = i-1

So i = 10 - 1 = 9. The decrement happens first and then print

i = 9

Question 61

Describe in Detail Essay▾

Can you write a function similar to printf () .

Edit

Explanation

  • In c programming language, printf () is used to print the “character, string, float, integer, octal, and hexadecimal values” onto the output screen.
  • To generate a newline, we use “” in C printf () statement.
  • Puts () function can be used similar to printf () .
  • Function int puts (const char ⚹ str) writes a string to stdout up to but not including the null character.
  • Puts in combination with sprintf can produce the “printf” . “sprintf” uses the format specifiers similar to printf but instead of directing output to stdout, it directs output to a string.
  • Puts outputs a newline character to the output.

Declaration:

int puts (const char ⚹ str)

Return Value:

  • str:
  • This is the C string to be written.

Example of puts () :

  1. #include <stdio.h>
  2. #include <string.h>
  3. int main ()
  4. {
  5. char str1[15];
  6. char str2[15];
  7. strcpy(str1, "tutorialspoint");
  8. strcpy(str2, "compileonline");
  9. puts(str1);
  10. puts(str2);
  11. return(0);
  12. }

OUTPUT:

tutorialspoint

compileonline