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

C & C Plus Plus
Edit

Write in Short

Short Answer▾

Does there exist any way to make the command line arguments available to other functions without passing them as arguments?

Explanation

  • We can copy them into global variable in the main () function
  • Then our other functions can use global variable.

Question 323

C & C Plus Plus
Edit

Write in Short

Short Answer▾

What is a modifier?

Explanation

  • A modifier, also called a modifying function is a member function that changes the value of at least one data member.
  • In other words, an operation that modifiers the state of an object.
  • Modifiers are also known as ‘mutators’ .

Question 324

C & C Plus Plus
Edit

Write in Short

Short Answer▾

How do you print a string on the printer?

Explanation

Following code gives an example:

const char ⚹ hello = “! ! ! Hello Printer! ! ! ⧵f” ;

if (WritePrinter (hPrinter, (void ⚹) hello, strlen (hello) , &dwBytesWritten) ) {

puts ( “printer opened” ) ;

}

Question 325

C & C Plus Plus
Edit

Describe in Detail

Essay▾

Write a program to generate the Fibonacci series.

Explanation

  1. #include<stdio.h>
  2. intmain()
  3. {
  4.     intn, first =0, second =1, next, c;
  5.     printf("Enter the number of terms");
  6.     scanf("%d",&n);
  7.     printf("First %dtermsofFibonacciseriesare);
  8.     for ( c =0 ; c <n ; c++ )
  9.     {
  10.         if ( c <= 1 )
  11.         next =c;
  12.         else
  13.         {
  14.             next =first +second;
  15.             first =second;
  16.             second =next;
  17.         }
  18.         printf("%d",next);
  19.     }
  20.     return0;
  21. }

OUTPUT

Enter the number of terms: 5

First 5 terms of Fibonacci series are:

0

1

1

2

3

Developed by: