LakshyaEducation.in

VEDIC MATHS Video Series
  • Home
  • Video Series
    • Vedic Maths Videos
    • Quantitative Aptitude Videos
    • Class 8 Maths Videos
    • Class 9 Maths Videos
    • Class 10 Maths Videos
  • Quiz & Solutions
  • Blog
  • Store
  • Login
  • Contact Us
  • Home
  • Topic
  • C Programming
  • Input / Output

C Programming

INPUT / OUTPUT MCQs

Total Questions : 35

Page 1 of 4 pages
Question 1.

Can we specify a variable filed width in a scanf() format string?


  1.    Yes
  2.    No
 Discuss Question
Answer is Option B. -> No

In scanf() a * in a format string after a % sign is used for the suppression of assignment. That is, the current input field is scanned but not STORED.

Question 2.


Will the following program work?



#include<stdio.h>

int main()
{
int n=5;
printf("n=%*d\n", n, n);
return 0;
}

  1.    Yes
  2.    No
 Discuss Question
Answer is Option A. -> Yes

It prints n= 5

Question 3.

A file written in text mode can be read back in binary mode.


  1.    Yes
  2.    No
 Discuss Question
Answer is Option B. -> No

The difference is that text files contain lines (or records) of text and each of these 

has an end-of-line marker automatically appended to the end of it whenever you 

indicate that you have reached the end of a line.

Binary files are not broken up into separate lines or records so the end-of line marker 

is not written when writing to a binary file.

So, we cannot read the correct the data in binary mode.

Question 4.

stderr, stdin, stdout are FILE pointers


  1.    Yes
  2.    No
 Discuss Question
Answer is Option A. -> Yes

Yes, these will be declared like

The corresponding stdio.h variable is FILE* stdin;

The corresponding stdio.h variable is FILE* stdout;

The corresponding stdio.h variable is FILE* stderr;

Question 5.

In a call to printf() function the format specifier %b can be used to print binary equivalent

 of an integer.


  1.    True
  2.    False
 Discuss Question
Answer is Option B. -> False

There is no format specifier named %b in c.

Question 6.

We should not read after a write to a file without an intervening call to fflush(), fseek() 

or rewind()


  1.    True
  2.    False
 Discuss Question
Answer is Option A. -> True

True, we should not be able to read a file after writing in that file without calling the below 

functions.

int fflush ( FILE * stream ); If the given stream was open for writing and the last i/o operation

 was an output operation, any unwritten data in the output buffer is written to the file.

int fseek ( FILE * stream, long int offset, int origin ); Its purpose is to change the file position

 indicator for the specified stream.

void rewind ( FILE * stream ); Sets the position indicator associated with stream to the

 beginning of the file.

Question 7.

Offset used in fseek() function call can be a negative number.


  1.    True
  2.    False
 Discuss Question
Answer is Option A. -> True

True, offset in fseek() function can be a negative number. It makes the file pointer to 

move backwards from the current position.

Declaration: retval = fseek( fp, offset, from );

Where:

FILE *fp; = points to the file on which I/O is to be repositioned.

long offset; = is an integer giving the number of bytes to move forward or backward in

 the file. This may be positive or negative.

int from; = is one of the manifests SEEK_SET, SEEK_CUR, or SEEK_END.

int retval; = is non-zero if the seek operation was invalid (e.g. on a file not opened with 

a "b" option); otherwise, the return value is zero.

Question 8.

A text stream is an ordered sequence of characters composed into lines, each line 

consisting of zero or more characters plus a terminating new-line character.


  1.    True
  2.    False
 Discuss Question
Answer is Option A. -> True

True, each line may contain zero or more characters terminated by a newline character.

Question 9.


Point out the correct statements about the program?



#include<stdio.h>

int main()
{
FILE *fptr;
char str[80];
fptr = fopen("f1.dat", "w");
if(fptr == NULL)
printf("Cannot open file");
else
{
while(strlen(gets(str))>0)
{
fputs(str, fptr);
fputs("\n", fptr);
}
fclose(fptr);
}
return 0;
}

  1.    The code copies the content of one file to another
  2.    The code writes strings that are read from the keyboard into a file.
  3.    The code reads a file
  4.    None of above
 Discuss Question
Answer is Option B. -> The code writes strings that are read from the keyboard into a file.

This program get the input string from the user through gets function and store it 

in the file f1.txt using fputsfunction.

Question 10.

While calling the fprintf() function in the format string conversion specifier %s can be

 used to write a character string in capital letters.


  1.    True
  2.    False
 Discuss Question
Answer is Option B. -> False

The %s format specifier tells the compiler the given input was string of characters

  • 1
  • 2
  • 3
  • 4
  • Next →
  • Share on Facebook!
  • Share on Pinterest!

Sub Topics

  • Arrays
  • Bitwise Operators
  • C Preprocessor
  • Command Line Arguments
  • Complicated Declarations
  • Const
  • Control Instructions
  • Declarations And Initializations
  • Expressions
  • Floating Point Issues
  • Functions
  • Input / Output
  • Library Functions
  • Memory Allocation
  • Pointers
  • Strings
  • Structures
  • Subleties Of Typedef
  • Variable Number Of Arguments

Topics

  • Computer Aptitude
  • SAIL Junior Officer (E-0)
  • 10th Grade
  • 11th Grade
  • 12th Grade
  • 4th Grade
  • 5th Grade
  • 6th Grade
  • 7th Grade
  • 8th Grade
  • 9th Grade
  • NCERT
  • Cat
  • Commerce
  • Computer Science
  • Engineering
  • English
  • General Knowledge
  • Ias
  • Management
  • Quantitative Aptitude
  • Reasoning Aptitude
  • General Studies (Finance And Economics)
  • Analytical Instrumentation
  • Biochemistry
  • Bioinformatics
  • Biology
  • Biotechnology
  • Bitsat
  • Business Statistics
  • C Programming
  • C++ Programming
  • Cell Biology
  • Chemistry
  • Cost Accounting
  • Drug And Pharmaceutical Biotechnology
  • Electrical Measurement And Instrumentation
  • Environment Management
  • Environmental Biotechnology
  • Enzyme Technology
  • Financial Management And Financial Markets
  • Gate
  • General Science
  • Geography
  • Heat Transfer
  • History And National Movements
  • Human Anatomy And Physiology
  • Human And Cultural Diversity
  • Human Resource Management
  • Indian Economy
  • Indian Geography
  • Indian History
  • Indian Polity
  • Instrumentation Transducers
  • International Relations
  • Life Sciences
  • Marketing And Marketing Management
  • Mass Transfer
  • Mechanics Of Materials
  • Microbiology
  • Neet
  • Professional Communication
  • Renewable Energy
  • Sociology
  • Surveying
  • Total Quality Management
  • Uidai Aadhaar Supervisor Certification
  • Virology

Recent Questions

Q.   The Frequency Of Oscillation At Compared To Earth Will Be

Q.   The Formula In Which Σ(x-x̅)² Is Divided By One Less ....

Q.   If....

Q.   What Is The National Sport Of Canada(in Winter And Summer)?

Q.   A Well-oiled Machinery For The Creation And Diffusion Of Fad....

Q.   Considering All 2-digit Natural Numbers, How Many Values Of ....

Q.   In A Gas Welding Of Mild Steel Using An Oxyacetylene Flame, ....

Q.   Which One Of Following Fuels Is Used By Slow Thermal Nuclear....

Q.   Answer The Questions On The Basis Of The Following Informat....

Q.   Who Discovered The Path Of Circulation Of Blood In The Human....

Q.   __________ Is Produced Using Molasses As The Starting Raw Ma....

Q.   &n....

Q.   `3....

Q.   The Ratio Of Mass Concentration Of Species A To The Total M....

Q.   Which Pesticide Killed Many Other Organisms Instead Of Only ....

Q.   Resolution Of A DVM Is Given By ____________

Q.   Who Has Hinted At The Possible Community Transmission Of The....

Q.   The Ability Of Money To Be Moved Easily Is Called:

Q.   EXORBITANT

Q.   An Inventory, Which Consists Of Partially Worked Goods Is Ca....

LakshyaEducation.in
Lakshya Education
Bhilai,Chattisgarh,India
Email: admin@lakshyaeducation.in Phone: 07893519977 (WhatsApp)

Quick Links

  • Vedic Maths
  • Quantitative Aptitude
  • Class – IX Maths
  • Class – X Maths
  • YouTube Channel
  • Maths Fast Trick
  • Blog

Our Services

  • About us
  • Privacy
  • TOS
  • Refund / Cancellation
  • Contact
  • Affiliate Program
  • Copyright © 2022 All Right Reserved | Lakshya Education     ( )
    Login / Register

    Your Account will be created automatically when you click the below Google or Facebook Login Button.
    •   Login With Facebook
    •  Login With Google
     Login With Email/Password