Languages [3i Infotech Placement]: Sample Questions 494 - 495 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 494

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

Question 495

Edit

Describe in Detail

Essay▾

What is a template?

Explanation

  • Template is foundation of generic programming, which involves writing code in independent of any particular type.
  • Provides blueprint for creating a generic class or a function.
  • Library containers like iterators and algorithms are examples of generic programming developed using templates.
  • For example a vector containing different kinds can be declared as vector < int > or < string > .

Two types of template:

Function Templates

  • Write a generic function that used for different data types.
  • Class Template
  • Function template, class templates are useful when a class defines are independent of data type.
Two Types of Template

Developed by: