c) 3 only Types, Pointers, Arrays & Structures in C++, Functions, Namespaces & Exceptions in C++, Source Files, Classes & Operator Overloading in C++, Derived Classes, Templates & Exception Handling in C++, here is complete set of 1000+ Multiple Choice Questions and Answers, Prev - C++ Programming Questions and Answers Random Numbers, Next - C++ Programming Questions and Answers Lambda Expressions, C Program to Find the File Size using File Handling Function, C++ Programming Questions and Answers File Streams and String Streams, What is Nested File Inclusion in C Programming, C++ Programming Questions and Answers Header Files Usage, C Programming Questions and Answers File Inclusion 2, Unix Questions and Answers File Handling System Calls 2, C++ Program to Print the Contents of File in Reverse Order, Object Oriented Programming MCQ Questions. delete[] b; The range for signed integers is -32768 to 32767. This operator increments the value of its operand then uses the value in context. Which of the following is not used as a file opening mode? Therefore, it will continue to print javatpoint. Use the LOF and Loc functions instead of EOF when reading binary files with Input, or use Get when using the EOF function.

25) How many instances of a class can be declared? Answer: A ios::curr from the current position. cout.write (b, l); A pointer to an int and a pointer to a double are of the same size. Explanation: Returns true if a file open for reading has reached the end is the correct statement about eof(). In the context of counter-controlled iteration, which of the following, Which data type should normally not be used to control a counting. Which of the following true about FILE *fp. C. myfile::open ("example.bin", ios::out); c) The logical AND of two expressions is true if and only if each of the conditions is true. What is the highest value assumed by the loop counter in a correct, What is produced by a for statement with a correct body and with. Thank you for this questions and excellent explainations. b) ifstream Our C++ questions and answers focuses on all areas of C++ programming language covering 100+ topics in C++, a) ios::set 5) Which of the following comment is correct when a macro definition includes arguments? Which of the following is the default mode of the opening using the fstream class? d) VTC Answer: (a) The opening parenthesis should immediately follow the macro name. not at end of file, continue reading numbers 5. exit(1); Interviewmania is the world's largest collection of interview and aptitude questions and provides a comprehensive guide to students appearing for placements in India's most coveted companies. #include , int main(void) Returns true if a file open for reading has reached the next word. fout.open("sentences.dat"); Since the separator used is "," the D option is correct. Explanation: This means, "X" is a four bit integer. c) ios::in What is the scope of extern class specifier? The correct option is (c) The symbolic constant EOF is defined in & value is -1, For a typical program, the input is taken using _________. C. Destructor method ofstream fout; (d) a continue statement can never appear in the else part of an if statement.

d) ios::beg. c) FILE is a keyword in C for representing files and fp is a variable of FILE type a) int B. ifstream Which of the following is used to create an output stream? i.seekg (0, ios :: end); 2. Sanfoundry Global Education & Learning Series C++ Programming Language. It's popularity has gained significantly in last few years as SAS is one of the most sought-after IT skill. 1. 40) Suppose that cPtr is a character pointer, and its current content is 300. 16) Which one of the following is a loop construct that will always be executed once? Note:Includes all required header files Which of the following true about FILE *fp, A. What is the qualifying input for the type specifier G? If the mode includes b after the initial letter, what does it indicates. This program's output will not appear in the new line because the \ n escape sequence has not been used in this program. Which is true for fgets? c) ios::cur Which statement automatically handles all the details of counter-controlled. All Rights Reserved. A text is made up of the characters a, b, c, d, e each occurring with the probability 0.12, 0.4, 0.15,0.08 and .25 respectively. Which statement about a correct for statement with an initialization. Which one is a syntactically wrong statement? something to read. b) ios::out This section focuses on the "File Handling" in C++ programming langauge. b) 2, 3 Import raw data files. c) To truncate an existing file to half On my screen, I can't see possible answers to Q24, there is just the Q and the explanation, but there are no possible choices (A:D)THX for your work! Please mail your requirement at [emailprotected] Duration: 1 week to 2 week. b = new char [l]; Note:Includes all required header files using namespace std; int main () { ofstream outfile ("find.txt"); for (int i = 0; i < 70; i++) { outfile << i; outfile.flush(); } cout << "Done"; outfile.close(); return 0; }, What is the output of this program? Very conceptual questions, helped me a lot, thankyou very good excercise to brushup the topics, My question Data a;Office ='stansys';Run;Output : StAnSyS, To continue reading you need to turnoff adblocker and refresh the page, SAS Base Certification is one of the most popular certification in analytics industry. With files opened for Random or Binary access, EOF returns False until the last executed Get statement is unable to read an entire record. Please continue the good work! Explanation: End1 is an I/O manipulator that takes effect in printing a new line '\ n' character and then flushing the output stream. Which of the following methods can be used to open a file in file handling? | i) Use of wx is more efficient. a) Statements preceding a for and statements in the body of a for should typically be merged into the for header. Which of the following statement is correct? #include d) Both A and B. { When a variable may assume many different values which must be tested, (b) multiple actions do not need to be enclosed in braces. 28) What will the result of num1 variable after execution of the following statements? fin.close( ); { Which header file is required to use file I/O operations? d) FILE is a stream, Answer: A A runtime error will occur because the value of the l variable will be ""-1"" if file doesn't exist and in line 13 we are trying to allocate an array of size ""-1"". Calling the stream's member function sync() causes an immediate synchronization. b) ios::end If abcdefg is the input, the output will be. // declare stream variable name, fin.open("myfile",ios::in); // Great Job on preparing some tricky questions for the SAS Examplease keep up the good work! What will be the new value in cPtr after the following assignment? Which is the only function all C programs must contain? 34) A class D is derived from a class B, b is an object of class B, d is an object of class D, and pb is a pointer to class B object. In a variable length argument function, the declaration can _______. fine = cin.get(); Study SET, MERGE and UPDATE statements. fseek() should be preferred over rewind() mainly because.

cout << course << endl; The comma operator is most often used in __________ statements. char * b; d) Returns true if a file open for reading has reached the middle. ________ iteration is sometimes called definite iteration. What is the output of this program? c) ios::cur c) Which stream class is to only write on files ? View Answer, 4. What is the use of ios::trunc mode? Explanation: This value (065) is an octal value, and it equals to the decimal value 53. Explanation: This program is a swapping program. //file will contain 5 apstring variables Which of the following is not used to seek file pointer? Thanks for the efforts. Which statement is used to skip the remainder of the body of an iteration statement and proceed with the next iteration of the loop? A pointer must point to a data item on the heap (free store). Mail us on [emailprotected], to get more information about given services. Which of the following methods can be used to open a file in file handling? } //get next number from file c) bool A directory of Objective Type Questions covering all the Computer Science subjects. Explanation: Lint is an analyzing tool that analyzes the source code by suspicious constructions, stylistic errors, bugs, and flag programming errors. a) True Which of the following statement is true? Using Open ( ) 15) What is the result after execution of the following code if a is 10, b is 5, and c is 10? Values of the control variable from 1 to 99 in increments of 1. Find the probability of rolling a 5 the first time and a 1 the second time. file

SAS Certification prep Guide for base programming 9 by SAS Institute, Really helpful explanations..! Answer: C All Rights Reserved. It should be " " to get "Of". a) ofstream Suppose the pointer variable has p address 1000, and that p is declared to have type int*, and an int is 4 bytes long. Very helpful. Explanation: fp is a pointer of FILE type and FILE is a structure that store following information about opened file, a) Using Open ( ) file, however, is often unknown. Explanation: The output of this program is "Hello, World!". The first object created is the first object destroyed; last created is last destroyed. a) ios::beg View Answer, 2. thank you for questionsit helped a lot. Note:Includes all required header files using namespace std; int main () { int p = 1000; double q = 3.14; cout << p; cout << endl; cout << q << endl << p * q; endl (cout); return 0; }, Which of the following is true about the following program Note:Includes all required header files using namespace std; int main () { char i; streambuf * p; ofstream of ("find.txt"); pbuf = of.rdbuf(); do { i = cin.get(); p -> sputc(i); } while (i != '. Explanation: Both A and B methods can be used to open a file in file handling. With files opened for Output, EOF always returns True. ifstream i; 36) Which of the following SLT template class is a container adaptor class? The ____________, __________, and ____________ are the only three forms, c) In the "Rules for Forming Structured Programs (and Structured Flowcharts)," the rule that states, "Any rectangle (action) can be replaced by any control statement" is called the "nesting rule.". The optimal coding tech-nique will have the average length of. Explanation: Any C program has at least one function, and even the most trivial programs can specify additional functions.

Which sets are best represented by the venn diagram. int data; Note:Includes all required header files using namespace std; int main () { int l; char * b; ifstream i; i.open ("find.txt", ios :: binary ); i.seekg (0, ios :: end); l = i.tellg(); i.seekg (0, ios :: beg); b = new char [l]; i.read (b, l); i.close(); cout.write (b, l); delete[] b; return 0; }, What is the output of this program? 1. How many objects are used for input and output to a string? Thanks for providing these good, accurate questions with thoughtful explanations for free. thanks a lot, Great Job Mr. Bhalla.. Keep up the good work. What is the default return-type of getchar()?

d) Point out the correct statements about the program? c) ios::cur #include Answer: (a) The program must have at least one function. a) ios::in View Answer, 11. B. myfile.open ("example.bin", ios::out); Which function is used in C++ to get the current position of file pointer in a file? int main () Attempt a small test to analyze your preparation level. Next Question. 49) What will the output after execution of the following statements? (b) using floating-point values as the counter in counter-controlled iteration. Which statement regarding the switch statement is false? Which of the following is the default mode of the opening using the ofstream class? //Works nicely as an end of file check. 2009 - 2022 by IndiaBIX Technologies. fout.close( ); 22) Which of the following will copy the null-terminated string that is in array src into array dest? Which of the following comments about EOF are true? C++ provides a special function, eof( b) ios::out Explanation: In the C language, the constant is defined anywhere, but starting on a new line. //open file to access information data; Explanation: In this program, it will first print the inner value of the function and then print the outer value of the function. A. myfile:open ("example.bin", ios::out); b) get_pos() D. None of the mentioned. The eof( ) function has been } fin >> 27) What is the maximum number of characters that can be held in the string variable char address line [40]? 29) What will the result of len variable after execution of the following statements? Usually the general format style of the file and the type of data Which of the following is a poor programming practice? // Answer: (c) Anywhere, but starting on a new line. known to be persnickety under certain conditions. X cannot be greater than a four-digit integer. end of file: //This example creates a file of apstrings Questions from Previous year GATE question papers, UGC NET Previous year questions and practice sets. The body of the loop will execute at least once. This set of C++ Programming Multiple Choice Questions & Answers (MCQs) focuses on File Handling. If the file is opened for output operations and it already existed, then a new copy is created. a) moveg() b) get_pos() c) Monetary calculations can be performed in C. d) The conversion specifier %7.2f prints a floating-point value with 4 positions to the left of the decimal point. The symbolic constant EOF is defined in & value is -1, Previous Question ii) If w is used, old contents of file are erased and a new empty file is created. It is not possible to combine two or more file opening mode in open () method. A. 13) How many times will the following loop execute? //for exit() apstring sentences, sent; View Answer.

a) ios::in Explanation: Both A and B methods can be used to open a file in file handling.

no more data to be read from an input file stream, and zero (meaning FALSE)

TRUE FILE is a structure and fp is a pointer to the structure of FILE type d) ios::trunc. The question was framed in such a way. JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Which of the following is used to move the file pointer to start of a file? Explanation: Macro is used in place of a function because it reduces code size, and very efficient. b) ios::start 24) Each instance of a class has a different set of, Explanation: Each instance of the class has a different set of attribute values. When wx is used, fopen() returns NULL if file already exists.

D. myfile.open ("example.bin", ios:out); Explanation: myfile.open ("example.bin", ios::out); is correct syntax. It first evaluates to "a + = 3" i.e. 32) Give the following declarations and an assignment statement. }, A. course Objects are destroyed in the order they appear in memory, the object with the lowest memory address is destroyed first. file contains an undermined number of integer values Which of the following statements are correct? Explanation: You can always declare multiple instances of a class, as per required. b) char c) Sentinels must be distinct from regular data items. contained within the file are known. A single die is rolled twice. its value is implementation dependent and cant be negative, its value should not equal the integer equivalent of any character, Following Operating System was Created by Dennis Ritchie. c) changep() Note:Includes all required header files What is the return type open() method? d) ios::beg Explanation: In C language, the pre-processor is a macro processor that is dynamically used by the C programmer to modify the program before it is properly compiled (Before construction, pro-processor directives are implemented).