You are on page 1of 18

Programming in C : BCA 104 / BSCIT 102/ MCA 102/ MSCIT 102

-----------------------------------------
Introduction to problem solving
-----------------------------------------
Q. ‘C is a middle level language’, comment on this statement.

High Level language:


A high-level programming language is a programming language that is more user-friendly, to some extent
platform-independent, and abstract from low-level computer processor operations such as memory accesses.

Low Level Language:


A low-level programming language is a programming language that is more machine specific, and for using
any resource of the Computer (such as any computer processor operations such as memory accesses) is
directly dependent on the language code.

Features of C:
It’s a middle level language because it includes some high end tasks like code abstraction and enforcement
and checking of data types, and some low level functions like ‘embedded’ use of assembly language and
direct output to ports or use of registers. That is why it has become so popular in programming 1) graphics
applications or 2) embedded systems. While it does not always require direct knowledge of the hardware you
are working on, it helps provide a direct and achievable path for using or even obtaining that knowledge, if we
really need it. C is a high level language because the syntax of loop controls, constructs looks like common
language (English-like) we used to communicate. For example if-else, for etc. But no doubt the C-language is
mainly used as system programming because of its flexibility viz pointers, case syntax, less confusion.
Though it is a high level language, but it is also very near to low level programming. C is high level since it
will give us all the features such as portability, documentabity etc.

Q. Differentiate between algorithm and flowchart.

An algorithm is a logical and concise list of steps required to solve a problem. An algorithm
is composed of a finite set of steps, each of which may require one or more operations. The
following example would explain algorithm more effectively.

Example: Calculate and print the sum of two numbers.

Step 1: Start
Step 2: Read the two number say A & B
Step 3: Add A & B and store it in C
Step 4: Print C
Step 5: Stop.

On the other hand, a flowchart is a pictorial representation of step-by-step solution of a


program. It is a good method of writing down the algorithm.
Example: a flowchart to find the sum of two numbers.

1
Programming in C : BCA 104 / BSCIT 102/ MCA 102/ MSCIT 102

-----------------------------------------
Fundamentals of C
-----------------------------------------
Q. Explain basic data types available in C with the help of example.

A data type of a variable is the type of data it can store.


The C data types may be classified into two categories:
Primary data type & Composite data type

Primary data type: These data types are in-built with C language. There are five primary data types in C
language.

2
Programming in C : BCA 104 / BSCIT 102/ MCA 102/ MSCIT 102

1. int : stores signed integers. The range is –32768 to +32767. E.g. positive or negative integers.
2. char : stores a single character belonging to the defined character set of C language. The range is –128 to
+128.
3. float : stores real numbers with single precision. Range is 3.4E-38 to 3.4E+38.
4. double : stores real numbers with double precision. Range is 1.7E-308 to 1.7E +308.
5. void : specify no values.

Composite data type: these data types allow the programmers to create their own data types.

Q. Discuss the various operators available in C with the help of example.

C operators can be classified into a number of categories. They include:

1. Arithmetic operators
2. Relational operators
3. Logical operators
4. Assignment operators
5. Increment and decrement operators
6. Conditional operators
7. Bitwise operators
8. Special operators

1. Arithmetic operators: These operators work on numeric type of operands. There are five
arithmetic operators in C.

2. Relational operators: These operators are used to compare two operands to see whether they are equal to
each other, unequal, or one is greater or less than the other. While the operands can be variables, constants or
expressions, the result is always a numeric value equivalent to either true or false. C language provides six
relational operators.

3
Programming in C : BCA 104 / BSCIT 102/ MCA 102/ MSCIT 102

3. Logical operators: Logical operators are used to combine two or more relational expression. C provides
three logical operators.

4. Assignment operators: These operators are used to store the result of an expression to a variable. The most
commonly used assignment operator is (=).
Ex. int a = 5;
char ch = ‘x’;
5. Increment and decrement operators: The increment operator (++) adds one to the current value of the
operand and stores the result back into the operand. The decrement operator (—) subtracts one from the
operand and stores the decremented value back into the operand.
6. Conditional operators: C provides a ternary operator called conditional operator, represented by :? . The
syntax of this operator is: A? B: C
Here A is a conditional expression resulting either true or false. If the value A is true, then expression
evaluates to B, otherwise C.
7. Bitwise operators : These operators are used for testing the bits, or shifting them right or left. These
operators are applicable to integer data types only.
8. Special operators : C language provides some special operators. These include comma operator, sizeof
operator, pointer operators (& and *) and member selection operators (. and ->) .

Q. What are constants? Discuss their types with examples.

Constants are fixed values that remain unchanged during the execution of a program and are
used in assignment statements.

The declaration for a constant in C language takes the following form:


Const <data_type> <variable_name> = <value>
Ex. Const float pi = 22/7;

C language facilitates five different types of constants.

4
Programming in C : BCA 104 / BSCIT 102/ MCA 102/ MSCIT 102

1. Integer
2. Character
3. Real
4. String
5. Logical

1. Integer Constant: An integer constant refers to a sequence of digits and has a numeric value. There are
three types of integers in C language, decimal, octal, hexadecimal.
Ex: Decimal Integers : 1, 56, 7657, -34 etc.
Octal integers : 076, -076, 05 etc.
Hexadecimal Integers : 0x56, -0x5D etc.

2. Character Constant: A character constant consists of a single character, single digit, or a single special
symbol enclosed within a pair of single inverted commas. The maximum length of a character constant is one
character.
Ex: ‘a’, ‘B’, ‘7’, ‘*’ etc.

3. Real or Floating point Constant: A number with a decimal point and an optional preceding sign
represents a real constant.
Ex: 34.8, -655.33, .2, -56.7, 7. etc.

4. String Constant: A string constant is a sequence of one or more characters enclosed within a pair of
double quotes (“”).
Ex: “a”, “123”, “Welcome to C programming” etc.

5. Logical Constant: A logical constant can have either true value or false value. In C, a non-zero value is
treated as true while 0 as false.

Q. How comments in C program are given? Explain with an example. What is the purpose of comments?

The lines beginning with /* and /* are known as comment lines. Comment lines are not executable statements and
therefore anything between /* and /* is ignored by the compiler. In general, a comment can be inserted wherever
blank space can occur- at the beginning, middle or end of a line, but never in the middle of a word.

Example:
main()
{
/*……………printing begins…………*/
printf(“Hello World”);
/*……………printing ends……………*/
}
Comments cannot be nested. So
/*—————/*———————*/——————*/
is not valid and therefore results in an error.
A comment can be split over more than one line, as in,
/* This is
a jazzy
comment*/

Such a comment is often called a multi-line comment.

Purpose of comments:
a) Comments are used in a program to enhance its readability and understanding.
b) Comments help the programmers and other users in understanding the various functions and operations of a
program and serve as an aid to debugging and testing.

5
Programming in C : BCA 104 / BSCIT 102/ MCA 102/ MSCIT 102

-----------------------------------------
I/O Functions
-----------------------------------------
Q. Explain briefly various character input/output functions with examples.

The functions that program input/output of one character at a time are known as character I/O functions.
Followings are the various character input functions:
1. getchar()
2. getch()
3. getche()
and the various character output functions are:
1. putchar()
2. putch()

getchar() & putchar(): getchar() function is used for reading a character from the keyboard.
Ex. ch = getchar();
This statement reads a character and stores it in variable ch of type char.
putchar() is the complementary function of getchar(). It is used to display a character on the
monitor. The following statement displays a character value on the monitor whatever is stored
inside ch at the current position.
putchar(ch);
getch() & putch() : getch() is used to accept a character from the keyboard and putch() is
used to print a character on the monitor.
The advantage of using getch() function is that neither the user is required to press enter key
after typing a character nor the typed character is echoed to the monitor.
getche(): We can also use getche() for receiving a character from the keyboard. The getche()
is basically: getch() + e
Here, the letter ‘e’ stands for echoes. Accordingly, it doesn’t wait for the enter key to be typed
and also echo the typed character to the monitor.

Q. What is interactive programming?

Interactive programming implies of the programming style where programs are developed in
such a way where :
• data elements involved in the processing are mostly accepted from user.
e.g scanf() or gets() functions in C
• some decision making opinions are chosen from user-end
e.g switch(switch-case) on a user given value
• In case of GUI, good number of mouse clicks from user end are involved at large extent
Click on buttons etc. on Visual Basic or Java Swing/AWT
• Some cases user are provided to do draw/drag-drop operations that are accepted as input to
• the program
e.g. Java Swing or AWT drawing packages

Interactive programming is much more user-centric thus involves special attention to the coding.
Also since user are allowed to make interaction with the program adequate validation of user
input is an important consideration.

-----------------------------------------
Control Flow statements
-----------------------------------------

6
Programming in C : BCA 104 / BSCIT 102/ MCA 102/ MSCIT 102

Q. Explain the difference between break and continue statements with example.

The break statement is used to skip the particular part of program code. It can be used in switch case and also
in various loops such as while, do, for. In case of loop, break statement is used to terminate the loop.
On the other hand, continue statement can be used only in the loops. It causes the loop to be continued with
the next iteration after skipping any statements in between.
The following fig illustrates the difference of these two statements in while loop:

Q. Differentiate between various loops available in C language?

The C language provides three constructs for performing loop operations. They are:

1. The while statement


2. The do-while statement
3. The for statement

Comparison of three loops:

7
Programming in C : BCA 104 / BSCIT 102/ MCA 102/ MSCIT 102

-----------------------------------------
Arrays
-----------------------------------------
Q. Draw a diagram to represent the internal storage of an array.

This is the internal memory representation of a single dimension integer array a[4]. Here a[4] indicates the
size of the array as 4.

The memory addresses 4001, 4003, ……4007 are contiguous memory locations although does not look like. It
is because as integer requires two bytes to store information in memory then for every element of the array a
memory location of size 2 bytes is reserved.

4001 = base address or the starting address of the array.

a[0], a[1],……a[4] where 0, 1, 2,…4 are called the subscript or indices of an array. Each subscript represents
the position of the elements stored in the array.

a[0] Zeroth or first element


a[1] Second element
a[3]The last element

Similarly for a float array the addresses will be 4001, 4005, 4009,4013. because the float
variable requires 4 bytes each as follows:

and that for a character type array will be 4001, 4002, 4003, 4004.

-----------------------------------------
String Manipulations
-----------------------------------------
Q. How can you create a string type C variable? Can they be assigned to each other in the
same way as other data types? Explain.

C does not support string as a data type. But it allows us to represent strings as character arrays. In C, a string
variable is any valid C variable name and is always declared as an array of characters.

Example: char city[10];


char name[30]b ;

8
Programming in C : BCA 104 / BSCIT 102/ MCA 102/ MSCIT 102

In assigning a character string to a character array, compiler automatically supplies a null character (‘\0’) at
the end of the string. So the size of the array should be equal to the maximum number of characters in the
string plus one.
character arrays can be initialized when they are declared.

Example: char city[9] = “NEW YORK”;


char city[9] = {‘N’, ’E’, ’W’, ’ ’, ‘Y’, ‘O’, ‘R’, ‘K’, ‘\0’};

When we initialize a character array by listing its elements, we must supply explicitly the null
terminator.
String variables cannot be assigned to each other as other variables. Such as,

char s1[4] = “abc”;


char s2[4];
s2 = s1;

is not allowed and will produce compiler error. An array name cannot be used as the left operand of an
assignment operator.
In doing this we have to use the string function strcpy(), which works almost, like a string-assignment
operator.
e.g. strcpy(s2, s1);

will assign the contents of string s1 to string s2.

-----------------------------------------
Functions
-----------------------------------------
Q. What are the different storage classes in C?

There are four storage classes in C :

a) Automatic storage class


b) Register storage class
c) Static storage class
d) External storage class

Automatic storage class:


Storage - Memory
Default initial value - garbage value
Scope - Local to the block in which the variable is defined
Lifetill the control remains within the block in which the variable is defined
Register storage class:
Storage - CPU registers
Default initial value - garbage value
Scope - Local to the block in which the variable is defined
Lifetill the control remains within the block in which the variable is defined.
Static storage class:
Storage – Memory
Default initial value - zero
Scope - Local to the block in which the variable is defined
Lifevalue of the variable persists between different function calls.
External storage class:
Storage - Memory
Default initial value - zero
Scope - Global
LifeAs long as the program’s execution doesn’t come to an end

9
Programming in C : BCA 104 / BSCIT 102/ MCA 102/ MSCIT 102

Q. Explain with the help of example the concept of passing array to functions.

Three rules to pass an array to a function

1. The function must be called by passing only the name of the array.
2. In the function definition, the formal parameter must be an array type, the size of the array
does not need to be specified.
3. The function prototype must show that the argument is an array.
To pass a one-dimensional array to a called function, the name of the array without any
subscripts and the size of the array are passed as parameter. For example,
largest(a, n)
will pass the whole array a of size n to the called function.
The prototype declaration of the same function may look like:
int largest(int a[], int size)

Example:
main()
{
int largest(int a[], int n); // function prototype
int value[4] = {3,12,22,10};
printf(“%d\n”,largest(value,4));
}
int largest(int a[], int n)
{
int j, max;
max = 0;
for(j=0; j<n; j++)
if(max>a[j])
max = a[j];
return(max);
}

In case of a two-dimensional array in the function definition, we must indicate that the array
has two dimensions by including two sets of brackets and the size of second dimension must
be specified as follows:
double average(int x[][n], int m, int n)
{
…………
…………
}

Q. Differentiate between passing one-dimensional array and two-dimensional array in specification of function
prototype and function definitions.

In case of one-dimensional array, in the function definition, the formal parameter must be an
array type; the size of the array does not need to be specified.

As for example:

int largest(int a[], int n)


{
…………
…………
return(expression)
}
But in a two dimensional array, in the function definition, we must indicate that the array has
two dimensions by including two sets of brackets and the size of second dimension must be
specified as follows:
double average(int x[][n], int m, int n)

10
Programming in C : BCA 104 / BSCIT 102/ MCA 102/ MSCIT 102

{
…………
…………
return(expression);
}

Q. Write a short note on Recursion v/s Iteration.

Recursion: recursion is a process where a function calls itself.

Iteration: The iteration constructs are an efficient method of handling a series of statements that must be
repeated a variable number of times.

Comparison between Iterative and Recursive approaches from performance considerations

Factorial:
//recursive function calculates n!
static int FactorialRecursive(int n)
{
if (n <= 1) return 1;
return n * FactorialRecursive(n - 1);
}
//iterative function calculates n!
static int FactorialIterative(int n)
{
int sum = 1;
if (n <= 1)
return sum;
while (n > 1)
{
sum *= n;
n—;
}
return sum;
}

As we can clearly see the recursive is a lot slower than the iterative (considerably) and limiting (stack
overflow).

The reason for the poor performance is heavy push-pop of the registers in the ill level of each recursive call.

11
Programming in C : BCA 104 / BSCIT 102/ MCA 102/ MSCIT 102

-----------------------------------------
Structures & Unions
-----------------------------------------
Q. Explain nesting of structures with example.

One structure can be nested within another structure. Using this facility, complex data types can be created.
We can nest a structure within another structure, which is in still another structure and so on…

The following program shows nested structure:

struct address
{
char phone[15];
char city[25];
int pin;
};
struct emp
{
char name[25];
struct address a;
};
struct emp e = {“jeru”, “531046”, “Nagpur”, 10};

Q. Explain array of structures with example.

In an array of structure, each element of the array represents a structure variable. Following program
illustrates this:
void main()
{
struct book
{
char name;
float price;
int pages;
};
struct book b[100]; // array b of structure book is declared.
int j;
for(j=0; j<=99; j++)
{
printf(“\nEnter name, price and pages”) ;
scanf(“%c%f%d”, &b[j].name, &b[j].price, &b[j].pages);
}
for(j=0; j<=99; j++)
printf(“\n%c%f%d”, &b[j].name, &b[j].price, &b[j].pages);
}

In an array of structure, all elements of the array are stored in adjacent memory locations. Since each element
of this array is a structure and since all structure elements are always stored in adjacent locations, so in the
above program b[0]’s name, price and pages in memory would be immediately followed by b[1]’s name, price
and pages, and so on.

Q. Explain with example passing of structures to function.

The structure variable can be passed to a function by passing either the individual structure
elements or the entire structure variable at one go. But to pass individual elements would
become more tedious as the number of structure elements go increasing, so a better way would
be to pass the entire structure variable at a time. This method is illustrated in the following

12
Programming in C : BCA 104 / BSCIT 102/ MCA 102/ MSCIT 102

program:

#include<stdio.h>
struct book
{
char name[25];
char author[25];
int callno;
};
void display(struct book);
void main()
{
struct book b1 = {“Let us C”, “YPK”, 101};
display(b1);
}
void display(struct book b)
{
printf(“\n%s%s%d”,b.name,b.author,b.callno);
}

Q. What do you mean by ‘Union’? How it can be declared and initialized in a C program?

Unions are derived data types. They are used to group a number of different variables together.
A union enables us to treat the same space in memory as a number of different variables.
A union can be declared using the keyword union as follows:
union item
{
int m;
float x;
char c;
} code;

This declares a variable code of type union item.

Q. Draw a diagram to represent the internal storage of a structure.

Whatever be the elements of a structure, they are always stored in contiguous memory locations.

Let us consider the following structure:

struct book
{
char name;
float price;
int pages;

13
Programming in C : BCA 104 / BSCIT 102/ MCA 102/ MSCIT 102

};
struct book b1 = {‘B’, 130.00, 550};

The elements of this structure are stored in the memory as shown in the figure.

Q. Give a brief description of various derived data types available in C.

There are mainly three derived data-types in C.

i. Structure:
It represents a record type, ideally.
May contain heterogeneous primitive / derived data types.
Can be self-referential also.
E.g.
struct
{
char name[50] ;
int roll;
double marks[3];
}student;

ii. Union:
Contains heterogeneous primitive / derived data types.
Largest sized element or data element forms the size of the union
All the members of union can not be used at the same time to get the best result
E.g.
union
{
float x;
int y;
char ch[2];
}myunion;

3) enum:
Enumeration of the member data are done purposefully
Enumeration value can be changed from default value
enum dept
{
accounts,
sales,
purchase,
production
};

Q. Explain the method of passing a structure by value as an argument to a function with an example of
prototype function declaration and function call.

The general syntax of passing a structure by value as an argument to a function is:

14
Programming in C : BCA 104 / BSCIT 102/ MCA 102/ MSCIT 102

function_name (structure_variable_name)
The called function takes the following form:
data_type function_name(struct_type st_name)
{
………
………
return(expression);
}
Example:
struct book
{
char name[25];
char author[25];
int callno;
};
void display(struct book) // prototype declaration
void main()
{
struct book b1 = {“Let us C”, “YPK”, 101};
display(b1); // function call
}
void display(struct book b)
{
printf(“\n%s %s %d”,b.name,b.author,b.callno);
}

The output:
Let us C YPK 101

-----------------------------------------
Pointers
-----------------------------------------
Q. Explain with example relationship between single dimension array and pointers.

When an array is declared, the compiler allocates a base address and sufficient amount of storage to contain
all the elements of the array in contiguous memory locations.

Suppose, we declare an array x as follows:


int x[5] = {1, 2, 3, 4, 5};

So if the base address of x is say,1000 then all the elements of the array will be stored as shown
in the fig.

Here, the array name x is defined as a constant pointer pointing to the first element, x[0] and
therefore the value of x is 1000, the location where x[0] is stored. That is,
x = &x[0]= 1000
if we declare p as an integer pointer, then we can make the pointer p to point to the array
x by the following statement:
p = x;

15
Programming in C : BCA 104 / BSCIT 102/ MCA 102/ MSCIT 102

Now we can access every value of x using p++ to move from one element to another. The
relationship between p and x is as follows:
p = &x[0] (=1000)
p +1 = &x[1] (=1002)
p +2 = &x[2] (=1004)
p +3 = &x[3] (=1006)
p +4 = &x[4] (=1008)

That is, the address of an element is calculated using its index and the scale factor of the data
type. For example:

Address of x[3] = base address + (3 X scale factor of int)


= 1000 + (3 X 2)
= 1006 So, Address of x[n] = base address + (n X scale factor of int)

So, when handing arrays, instead of using array indexing, we can use pointers to access array element. For
example,
*(p + 3) gives the value of x[3].

Pointer accessing method is much faster than array indexing.

Q. Explain with the help of examples pointer arithmetic.

Like ordinary variables, various arithmetic operations can be performed with the pointers. Such
as:
a. Pointers can be incremented or decremented.
int a=5, *ptr;
ptr=&a; // ptr=65524
ptr++; // ptr=65526
This will create a new storage locations, which will be the previous address +2 (for integer
variable) in the memory for the variable a.

b. Addition of a number to a pointer.


int x=4, *p, *ptr;
p = &x;
p= p+9;
ptr = p+3;

c. Subtraction of a number from a pointer.


int x=4, *p, *ptr;
p = &x;
p= p-6;
ptr = p-2;

d. Subtraction of one pointer from another


One pointer variable can be subtracted from another provided both variables point to elements
of the same array. The resulting value indicates the number of elements separating the
corresponding array elements.
void main()
{
int arr[] = {10, 20, 30, 40, 45, 78, 56};
int *p, *q;
p= &arr[1];
q= &arr[5];
printf(“%d %d”,q-p); // output, 4.
}

e. Comparison of two pointer variables.


Pointer variables can be compared provided both variables point to objects of the same data

16
Programming in C : BCA 104 / BSCIT 102/ MCA 102/ MSCIT 102

type. So if p1 and p2 are two pointer variable pointing to say,integer variable, then p1>p2,
p1 ==p2, p1!=p2 are allowed.
Following operations cannot be performed with the pointers:
1. Addition of two pointers.
2. Multiplication of two pointers.
3. Division of two pointers

Q. Explain with example the relationship of two-dimensional arrays with pointers.

pointers can be used to manipulate two-dimensional arrays as well.


An element in a two-dimensional array a can be represented by the pointer expression as
follows:
*(*(a+i) + j) or *(*(p+i) + j) , where p is the pointer variable.
Suppose we declare an array a as follows:
int a[2][3] = { { 15, 27},
{ 22, 31};
{ 14, 23}
};

The elements of a will be stored as :

If we declare p as an int pointer with the initial addess of &a[0][0], then


a[i][j] is equivalent to *(p+4 X i+j)
If we increment i by 1, the p is incremented by 4, the size of each row. Then the element a[2][3]
is given by *(p+2 X 4+3) = *(p+11).

Q. Describe Dynamic memory allocation and its functions.

C language requires the number of elements in an array at compile time. But our initial judgment
of size, if it is wrong, may cause failure of the program or wastage of memory space. So there is a process of
allocating memory at run time is known as dynamic memory allocation.

Fig shows the conceptual view of storage of a C program in memory. The memory space that is located
between stack and permanent storage area is available for dynamic allocation during execution of the
program. This free memory region is called the heap. The size of the heap keeps changing when program is
executed due to creation and death of variables that are local to functions and blocks.

17
Programming in C : BCA 104 / BSCIT 102/ MCA 102/ MSCIT 102

There are four library routines known as “memory management functions” that can be used for allocating and
freeing memory during program execution. They are:
malloc: allocates request size of bytes and returns a pointer to the first byte of the allocated
space.
Example: ptr = (int *) malloc (100 * sizeof(int));

On successful execution of this statement, a memory space equivalent to 100 times the size of an int bytes is
reserved and the address of the first byte of the memory allocated is assigned to the pointer ptr of type of int.
calloc: allocates space for an array of elements, initializes them to zero and then returns a pointer to the
memory.
Example: ptr = (int *) calloc (10, sizeof(int));

free: free previously allocated space.


Example: free(ptr);

Here, ptr is a pointer to a memory block which is released by the free function.
realloc: modifies the size of previously allocated space.
Example: ptr = (int *) realloc(ptr, 20);

On successful execution of this statement, a new memory space size 20 is allocated to the pointer variable ptr
and returns the pointer to the first byte of the new memory block.

-----------------------------------------
FILE handling
-----------------------------------------
Q. How can you create a data file in C?

Creating a data file means opening a file in the writing mode. When the mode is ‘writing’, a file with the
specified name is created if the file does not exist.
FILE *p;
p = fopen(“samplefile”, “w”);
the above statements open the file “samplefile” in the writing mode. If any file named “samplefile” already
exists, its contens are deleted and the file is opened as a new file. The following program shows how to create
a new data file and write data into it.
#include <stdio.h>
main()
{
FILE *f1;
char c;
printf (“Data input\n\n”);
f1 = fopen(“INPUT”, “w”); // create the file “INPUT”
while((c= getchar()) != EOF) // get a character from keyboard
putc(c, f1) ; // write a character to INPUT
fclose(f1); // close the file INPUT
printf (“Data output\n\n”);
f1 = fopen(“INPUT”, “r”); // reopen the file “INPUT”
while((c= getc(f1)) != EOF) // read a character from keyboard
printf(“%c”, c) ; // display a character on screen
fclose(f1); // close the file INPUT
}

OUTPUT
Data input
This is a program to test the file handling features
Data output
This is a program to test the file handling features

18

You might also like