3i Infotech Papers: Sample Questions 955 - 958 of 1245

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 955

» Languages » C & C Plus Plus

Short Answer Question▾

Write in Short

When is a memory allocated to a class?

Explanation

Unsderstanding of allocated to a class.

Unsderstanding of Allocated to a Class.

Unsderstanding of allocated to a class.

  • Memory is allocated when instance of a class is created.

  • A class is a template- allocated memory when object of that class is created.

Question number: 956

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

Can we specify variable field width in a scanf () format string? If possible how?

Explanation

  • It is possible to specify variable field width in a scanf () format string by using % s control string.

  • The % s reads string of variable field width up to the first white space character.

Example:

scanf (“%s”, name); // where name is a character array

  • The scanf () stores results in variables provided in argument list.

  • Note that scanf reads the data from the console or from a FILE stream and parses it.

Question number: 957

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

Write program for string reversal & palindrome check.

Explanation

  1. #include<stdio.h>
  2. #include<string.h>
  3. main()
  4. {
  5.     char str[50], revst [50];
  6.     int i=0j=0;
  7.     printf(“enter the string to reversed: “);
  8.     scanf(“%s”, str);
  9.     for(i=strlen(str)-1;i>0;i--)
  10.     {
  11.         revst[j]=str[i];
  12.         j++;
  13.     };
  14.     revstr[j]=”;
  15.     printf(“input string : %s”, str);
  16.     printf(“output string: %s”, revstr);
  17.     getch();
  18. }

Question number: 958

» Languages » Java

Essay Question▾

Describe in Detail

To get string of words.

Explanation

  • To get string of words is Gets ().

  • Gets () accepts single or multiple characters of string including spaces from the standard input device.

    How to declare:

gets (variable_name);

Example of declaration:

char ch [10];

gets (ch);

  • Gets () read string from the screen.

  • Gets () statement encounters the characters entered by user will be copied into the variable.

  • Gets () uses stdin (Standard Input Output) as source, but it does not include the ending newline character in the resulting string and does not allow to specify a maximum size for string variable.