c programming 2018

2nd Semester

Year 2018

Group B

2.Write a program to input two integer as arguments and display sum of those numbers
//i am using arguments without return type

 

  1. write a program to write “hello world” to file hello.dat

 

  1. Write a program for nested structure

 

  1. Write a program to input on integer as argument and pass the factorial number of one less number

  1. Write a program to add numbers at even position of integer array of size 50

 





Group C

Why files are used in program? Describe sequential and random access of file and also explain any two file handling functions.
Ans: Files are created for the permanent storage of data.

  • Sequential access of file:

In sequential access, to access data in the file, all data from the start must be accessed and discarded up to that location. The main disadvantage is that all the preceding data must be read. If the desired data is at the end of the storage, all previous data from the top must be accessed. Sequential access is only means of accessing data in some devices like tape drive. In some cases, it is the access method of choice, for example if we simply want to process a sequence of data elements in order.

  • Random access of file:

Random access permits direct access to a specific portion of a file randomly. For random access, we use function fseek( ) to set the file position, ftell( ) to return the current value of the file position and the function rewind( ) to reset the current value of the file position.
File handling functions:

  1. fopen( ) : It creates a new file or opens an existing file
  2. fclose( ) : fclose( ) function closes an opened file

 
Differentiate between switch…case and if…else statement. Write importance of conditional statements.

 
Importance of conditional statements are:

  • It is used for decision making purposes (if statement)
  • To execute a single statement or a compound statement (if-else statement)
  • To check the series of conditions (multiway conditional statement)

 

Leave a Reply

Your email address will not be published. Required fields are marked *