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

C & C Plus Plus
Edit

Describe in Detail

Essay▾

What is the output of the following program?

  1. main()
  2. {
  3.     charstr1[] ={‘s’,’o’,’m’,’e’};
  4.     charstr2[] ={‘s’,’o’,’m’,’e’,’⧵0’};
  5.     while (strcmp(str1,str2)) printf(“Stringsarenotequal”);
  6. }

Explanation

In the program

Table Shows the Program
char str1 [] = { ‘s’ , ‘o’ , ‘m’ , ‘e’ } ; char str2 [] = { ‘s’ , ‘o’ , ‘m’ , ‘e’ , ‘⧵0’ } ;
  • Given the two character arrays str1 and str2.
  • If a string constant is initialized explicitly with characters, ‘⧵0’ is not appended automatically to the string.
while (strcmp (str1, str2) )
  • Strcmp compares the str1 and str2
  • Since str1 doesn՚t have null termination
  • It treats whatever the values that are in the following positions as part of the string until it randomly reaches a ‘⧵0’ .
printf ( “Strings are not equal” ) ;
  • str1 and str2 are not the same
  • So, printf prints Strings are not equal

Question 84

C & C Plus Plus
Edit

Describe in Detail

Essay▾

What are models and meta models?

Explanation

  • Model:-
    • It is a complete description of something (i.e.. . system) .
    • A model is a simplification of reality with theoretical abstractions
  • Meta Model:-
    • Describes the model elements, syntax, and semantics of the notation allowing their manipulation.
    • A metamodel or surrogate model is a model of a model
    • Metamodeling is the process of generating such metamodels.
    • Metamodeling is the analysis, construction, and development of the frames, rules, constraints, models and theories applicable and useful for modeling a predefined class of problems.

Developed by: