Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 317 - 318 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 317

C & C Plus Plus
Edit

Describe in Detail

Essay▾

Can you use the function fprint () to display the output on the screen?

Explanation

Yes function fprint () can display the output on the screen.

fprintf syntax:

int fprint (FILE ⚹ stream, const char ⚹ format, parameters) ;

  • When stream is stdout output is directed to the screen. For example fprintf (stdout, “yes” ) ; will print yes on the screen. Note that
    • Stdout is standared output stream.
    • Stdin is standard input stream
    • Stderr is standard error stream
  • This happens because stdout is also a file pointer to the standard output (screen) .

Question 318

C & C Plus Plus
Edit

Describe in Detail

Essay▾

Find the output for the following C program

  1. #include<stdio.h>
  2. main ()
  3. {
  4.     chars1[] =“Ramco”;
  5.     chars2[] =“Systems”;
  6.     s1 =s2;
  7.     printf ( “%s” ,s1);
  8. }

Explanation

  • In the program
Table Showing the Program
char s1 [] = “Ramco” ;
  • define the character array s1 [] = “Ramco”
char s2 [] = “Systems” ;
  • define the character array s2 [] = “Systems”
s1 = s2;
  • Here s2 is assigned to s1 but not s1 is not a modifiable lvalue it is fixed array.
  • An lvalue refers to an object that persists beyond a single expression. You can think of an lvalue as an object that has a name. All variables, including nonmodifiable variables are lvalues
L Value Assingnment

Developed by: