Languages [3i Infotech Placement]: Sample Questions 90 - 92 of 546

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

Question 90

Edit

Write in Short

Short Answer▾

Name some pure object oriented languages.

Explanation

  • Smalltalk
  • Java
  • Eiffel
  • Sather

Question 91

Edit

Describe in Detail

Essay▾

What is the output of the following program?

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

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 92

Edit

Describe in Detail

Essay▾

Can you write a function similar to printf () .

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. intmain ()
  4. {
  5.     charstr1[15];
  6.     charstr2[15];
  7.     strcpy(str1, "tutorialspoint");
  8.     strcpy(str2, "compileonline");
  9.     puts(str1);
  10.     puts(str2);
  11.     return(0);
  12. }

OUTPUT:

tutorialspoint

compileonline

Developed by: