CS Interview Question & Answers

Feb 17 • Resources • 61755 Views • 64 Comments on CS Interview Question & Answers

CS Interview Question Answer

Q1. What do you mean by a File?
Ans: A File contains contains data/information which are stored permanently in a storage device.Floppy disk and hard disk are commonly used to store file information.When large quantity data is required to be stored and processed, the concept of file is used.

A file stored in a storage device is always identified using a file name(e.g. STUDENT.DAT).

Note:- A filename normally has a primary name and a secondary name which are separated by a Dot(.)

CS Jobs

Computer Science

Q2. Why we use File Handling?
Ans: The input and output operation that we have performed so far were done through screen and  keyboard only.After the termination of program all the entered data is lost because primary memory is volatile . if the data has to be used later ,then it becomes necessary to keep it in permanent storage device. so the c language provide the concept of file through which data can be stored on the disk or secondary storage device.The stored data can be read whenever required.

Types of File Handling in C:
The file handling in C can be categorized in two types-

  1. High level (Standard files or stream oriented files)- High level file handling is managed by library function. High level file handling is commonly used because it  is  easier and hide most of the details from the programmer.
  2. Low level (system oriented files)-  low level files handling is managed by system call.

Q3: What are the ways of storing data in Files?
Ans: There are two ways of storing data in files-
1. Text Format- In text format data is stored as a line of character with each line  terminated by a new line character (‘\n’). Text files are in human readable form and they can be created and read using any text editor.

2. Binary Format In binary format, data is stored on the disk same way as it is represented in the computer memory.Binary files are not in human readable form they and can be created and read by a specific program  written for them .The binary data stored in the file can’t be read by any editor.

The input and output operation in binary files take less time as compared to that of the text files because in binary files no conversion have to take place .However the data written using binary format is not very portable since the size of data types and byte order may be different on different  machine. In text format , these problem do not arise,and hence it is more portable.

Q4: What are the operations that can be performed on Files?
Ans: Following operations can be performed on files-

  1. Creation of a file of a specific type.
  2. Reading/processing a file.
  3. Append/add information to a file.
  4. Modify/edit data in a file.
  5. Delete items in a file.
  6. Update the file.

Q5: What are the measures that can be adopted to avoid errors in File Processing?
Ans: Following are the measures that can be adopted to avoid errors in file processing-

  • ferror() function can be used to detect any error during file accessing.This function will return a zero when there is no error or vice-versa.

FILE *fptr
if(ferror(fptr)==0)
printf(“\n The file is available for processing”);
else
printf(“\n Error in accessing file”);

  • To verify whether a file exists in the disks,the following definitions will help.

if(fptr==NULL)
printf(“\n No content or file does not exist”);

Q6: List some of the most used File Processing functions in C?
Ans: Most used file processing functions in C are-

  • fopen()-used to open a file and set the file pointer to the beginning or end of a File.
  • fclose()-used to close an active File.
  • getc()-used to read a character in a File.
  • putc()-used to write a character to a File.
  • putw()-used to write an integer data to a File.
  • fscanf()-used to read data from a File.
  • fprintf()-used to write data to a File.
  • rewind()-used to move the file pointer to the beginning of a File.

Q7: In what way is a file more flexible than a String?
Ans: A file is stored permanently in a storage device.It is easy to access a file whenever required. On the other hand, a string is stored temporarily in RAM, and the contents of a string will be erased automatically when the power is switched off or when the program execution is terminated.

Q8: Write the general formats for file opening and file closing commands?
Ans: For Opening:-

fp=fopen(“filename” , “mode”);
where ‘fp’ refers to the file pointer.
‘filename’ refers to the name of the file to be opened.
‘mode’ refers to the mode of accessing data.

For Closing:-
fclose(fp); where fp denotes the file pointer.

Q9: What do you mean by File Positioning? 
Ans: The file positioning of a stream describes where in the file the stream is currently reading or writing. I/O on the stream advances the file position through the file. On GNU systems, the file position is represented as an integer, which counts the number of bytes from the beginning of the file.

Q10:  What is the difference between a sequential file and a random file?
Ans: Sequential file access is the method employed in tape drives where the files are access in a sequential manner. So if you have to get a file in the end of the tape you have to start from the beginning till it reaches the beginning of the files…
Random access files are similar to the one in Hard Disks and Optical drives, wherever the files is placed it will go to that particular place and retrieve it.

Get the important interview questions for CS Students in pdf CS INTERVIEW QUESTION ANSWER.pdf

So here are the important CS Interview question & Answers for you. Give your feedback in the comments, its help us to know what you really need.

Related LInks-
C# Interview Questions and Answers
Important C interview questions with answers
C++ Interview Questions and Answers with PDF
Interview questions on JAVA

Tell us Your Queries, Suggestions and Feedback

Your email address will not be published.

64 Responses to CS Interview Question & Answers

  1. Uday says:

    Hi There,

    Seems like I won the lottery here….This is a treasure box of blogs and your folks are like leprechauns! Phenomenal read on CS Interview Question & Answers

    Consider an n bit binary number. If the number is to be encoded in Octal, how many Octal digits would be required approximately?

    if u say n/3 then u r r* bt will get half marks only.
    Right answer is: Ceil(n/3)

    Very useful article, if I run into challenges along the way, I will share them here.

    Merci,
    Uday

  2. Anonymous says:
  3. Anonymous says:
  4. Anonymous says:
  5. Anonymous says:
  6. Anonymous says:
  7. Jenifer says:

    Updated questions needed, sir

  8. Jenifer says:
  9. siva says:

    M,SC(COMPUTER SCIENCE)

  10. siva says:

    M,SC(COMPUTER SCIENCE)

  11. siva says:
  12. niloysen says:

    help

  13. niloysen says:
  14. Anonymous says:
  15. Ishtiaque Iqbal says:
  16. Ishtiaque Iqbal says:
  17. Ishtiaque Iqbal says:
  18. Ishtiaque Iqbal says:
  19. Ishtiaque Iqbal says:
  20. Ishtiaque Iqbal says:
  21. Ishtiaque Iqbal says:
  22. Ishtiaque Iqbal says:
  23. nandigama anusha says:

    how to prepare for aptitude questions

  24. garima sharma says:
  25. Nasir says:

    Computer science interview questions

  26. Ramya says:

    C basic

  27. Ramya says:

    C basic

  28. ROOPA H N says:

    please give me some important interview tips of c++ language

  29. ROOPA H N says:

    please give me some important interview tips of c++ language

  30. chitra bhatt says:
  31. rajakumar says:

    cse interview questions and guide for attend interviw

  32. poorna says:
  33. krishna kavuru says:

    no

  34. Bibek Chakraborty says:

    how to crack interviews for the first time?
    important questions related software jobs.
    which subjects are most important for a software job?

  35. Shikhagupta says:

    Lab instructor ki job K liye kin subject pr preparation Kare

  36. MICHAEL says:

    know the most interview questions for computer science

  37. Monika Bhardwaj says:

    what are the general questions for it companies technical round

  38. Manzoor Ullah says:

    student of computer science at shaheed benazir bhutto university dir upper

  39. rambo says:

    Respected, our campus drives are soon going to surprise us with ample of opportunities to grab a job by the aspirants and i was with the percentage below the preferable grade but i was acquainted with enough skills to get a job then how can i cope up with the situation ahead of me please guide me to the destination

  40. karan bawangarh says:

    i want ed to face an interview for computer science lecturer in few days how do i prepare

  41. suhashini says:

    how improve my tecnical skill
    plz send me how speak english

  42. Medha Sharma says:

    computer science teacher interview question and answers download in pdf for govt and pvt school

  43. sravanthi says:

    can you please send me any tips for getting job in top mnc’s

  44. Manickam.R says:

    How to do attend an lecturer job interview in polytechnic colleges?

  45. b. ramu says:

    i am like software jobs. prasent iam pg 1st year in kakatiya univercity. my dout is how to prepare job interview and what ask.

  46. sakthivel.s says:

    i want about c program , interview skills ,communication skills

  47. Arvind says:

    what is the new syllabus of GATE 2017? is there mathematical appittude? please provide me complete syllabus and knowledge.
    thanks

  48. Isha chawla says:

    no queries till now, if it is there then we can tell you

  49. Ankit says:

    I have currently passed b.tech(computer science engineering) 2nd yaer.
    What is the procedure and ways to get nob in government sector for computer student?
    Kindly guide me what should I do to get a job?

  50. ANISHA RAVIKUMAR J says:

    PLEASE HELP ME TO GET FREQUENTLY ASKING INTERVIEW QUESTIONS IN COMPUTER SCIENCE AND ENGINEERING ,SO THAT I CAN ATTENT INTERVIEW IN IHRD COLLEGE.

  51. kavitha says:

    how to prepare UPSC Exam relevant job for lecture of computer science

  52. Andhrews .A says:

    I Need Interview question and answer for B.sc Computer Science

  53. PRATHMESH PATIL says:

    Dear Sir,
    I m in my final year of my BE from Computer science and i m confused what to do? whether i should go for Computer advance course and get a job or prepare for CAT exam to get good MBA colleges for masters as they are more paid ?
    Please suggest me sir !!!
    Regards,
    Prathmesh Patil

  54. Prem Murmu says:

    terms asked in java interviews and basic terms canbe asked in interview for computer software student

  55. anitha says:

    i need type of questions to be asked for cse students

  56. chandan kumar says:

    study material for technical interview question computer science branch

  57. Hardik Sanghvi says:

    really helpful writting… provides hints on popular and commonly asked interview questions

  58. Shruti Priya says:

    IT Sector is a growing industry and thus, there is lots of scope for employment. Now-a-days people want to join the different IT industries but find difficulties in cracking the interview round. I would suggest everyone who aspire to join the software companies to go through this article.

  59. diya mukherjee says:

    preapring for job interviews? now just relax angd go through the questions of this site. it helps you to crack interviews in a simpler and smarter way.

  60. sumit mukherjee says:

    It is a compact information on the file handling and about its processing with errors. So helpful data while dealing with file handling.

  61. Arpita Sardar says:

    This is really helpful to get an idea about the questions as well as answers that asked in any Interview round.

  62. Abhinav Gupta says:

    very nice questions on file in c.all topics are nicely covered.

  63. Divya Acharya says:

    If you want to make your career in cs field then you must go through these question as they help you out in making a good career.

  64. Shilpa Ranjan says:

    These are some of the important interview questions related to CS. very commonly asked questions related to file and and other concepts are clearly explained in the answers. If you are searching for such set of questions then this can help you out ..!!!

« »