0% found this document useful (0 votes)
463 views42 pages

Overall C Question Bank For Students

Unit – I Introduction to C Part-A This document contains questions to test knowledge of basic C programming concepts including: 1) Data types like int, float, and char 2) Variables, constants, identifiers 3) Input/output functions like scanf(), printf() 4) Operators like arithmetic, relational, logical, and conditional 5) Control flow statements like if-else, for, while, do-while, switch 6) How to write simple programs to calculate results, read input, and display output. Part-B This section defines key terms like identifiers, keywords, variables, constants. It provides syntax for declaring

Uploaded by

Priyadarshini.R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
463 views42 pages

Overall C Question Bank For Students

Unit – I Introduction to C Part-A This document contains questions to test knowledge of basic C programming concepts including: 1) Data types like int, float, and char 2) Variables, constants, identifiers 3) Input/output functions like scanf(), printf() 4) Operators like arithmetic, relational, logical, and conditional 5) Control flow statements like if-else, for, while, do-while, switch 6) How to write simple programs to calculate results, read input, and display output. Part-B This section defines key terms like identifiers, keywords, variables, constants. It provides syntax for declaring

Uploaded by

Priyadarshini.R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

Unit – I Introduction to C

Part-A
1. C language is -----------
a)high level b)low level c)middle level d)assembly level
2 .Identifier consist of
a)letter b)keyword c)constant d)function
3. The size occupied by short int is
a)2 b)4 c)3 d)1
4. The format specifier for float is
a)%f b)%ld c)%u d)%c
5. a,b,c are the integer variables , whose values are 1,2,3. What is the return value of the
expression (a+b)>=c
a)0 b)1 c)3 d)2
6. main()
{printf(“a++ = %d”,a++);} what is the output of the program?
a)0 b)11 c)12 d)10
7. Evaluate the expression 9-12/3+3*2-1.

a)11 b)3 c)10 d)23

8. Which has the highest priority


a)* b)() c)>> d)—
9. Which is the valid filename in c?
a)system b)system.cpp c)system.c d)sys
10. n++ is equivalent to the expression
a)n=n+1 b)n=n-1 c)n=n+2 d)n+1
11. Which is not a real constant?
a)15.34 b)10 c)0.87 d)19.8
12 Which of the following is not a string?
a)”s” b)’s’ c)”\”s\”” d)”a”
13. Which command is used to get input from the user?
a)cout b)cin c)scanf() d)printf()

1
14. Which of the following is a string constant?
a)’5’ b)”hello” c)25 d)”6

15. Which of the following is not a variable?


a)% b)height c)xy1 d)k_ct
16 .Which of the following function is used to display the output?
a)scanf() b)printf c)cin d)main()
17. if statement is used for
a)looping b)decision making c)arrays d)nest loop
18. The range of char data type is
a)-128 to +127 b)3.4e-38 to 3.4e+38 c)1.7e-308 to 1.7e+308 d) 127
19. Which of the following is not a keyword?
a) auto b)break c)case d)stdio
20. Which is not a formatted i/o function?
a)scanf() b)fscanf() c)gets() d)printf()
21. Which is a top tested looping statement?
a. while b. do..while c. for d. repeat
22.The output of the statement is for( ; ; )
a. infinite loop, b. syntax error c. compilation error d. logical error

Part-B
1. What is an identifier?

Identifier are names given to various program elements such as variables , functions and
arrays.

2.What are called keywords?

Certain reserved words are called keywords, that have standard and predefined meaning
which cannot be changed. Example: auto, break, case, else, if , int etc.

3. Write the syntax for declaring variables, with example.

Data type v1,v2,….vn

Ex: int code; float price;

4. Differentiate constant and variables


2
A variable may take different values at different times during the execution.

The value of the variable, whose values cannot be changed during the execution of the
program are called constants.

5. Write the syntax of scanf() function?

scanf(“control string”,&arg1,&arg2,…&argn);

Here the control string specifies the field format and &arg1, &arg2 specifies the address of the
variable.

6. What do you meant by operator?

Operator is a symbol which performs operation on operand.c=a+b, here + and = are


operators.

7. What is size of operator?

It is a compile time operator and when used with an operand, it returns the number of
bytes occupied by the operand.

8. What is the use of goto statement?

The goto statement can cause program control almost anywhere in program
unconditionally, it require a label to identify the place to move the execution.

9. Difference between break and continue.

S.No break continue


1 It takes the control to It takes to the beginning of
outside of the loop the loop

2 It is also used with switch Used only with loop


statement statements

3 Syntax: Syntax:
break; continue;

10. What is use of switch statement?

It is the multi way decision statement, allows to make decision from number of choices,
if match is found the block of statements associated with it is executed.

3
11. Write the syntax of if else statement.

if(test expression)

{ true block}

else

{ false block}

Statement-x;

12.Write a c program to find greatest of three numbers.

#include<stdio.h>
main()
{ int a,b,c;
printff(“enter a b and c”);
scanf(“%d%d%d”,&a,&b,&c);
if(a>b)
{ if(a>c) printf(“%d”,a);
else printf(“%d”,c);}
else { if(c>b)
printf(“%d”,c);
else printf(“%d”,b);}}

13. Write a c program to print the given two numbers is equal or not.

#include<stdio.h>

main ()
{ int a, b;
printf(“enter two numbers”);
scanf(“%d%d”,&a,&b);
if(a==b)
printf(“a and b are equal”);
else printf(“a and b are not equal”); }

14. Write the syntax for switch statement.

switch (expression)
{ case constant 1:
Block1; break;
case constant 2:
Block2; break;
4
.
.
default: break; }

15. Write a c program to find the given number is odd or even.


#include<stdio.h>
main ()
{ int num,rem;
printf(“enter the number”);
scanf(“%d”,&num);
rem=num%2;
if(rem==0)
printf(“even number”);
else printf (“odd number”):
}

16. List the difference between while and do..while statement?

S.No While Do…while


1 This is the top tested loop This is the bottom tested loop
2 Condition is first tested if the condition It executes the body once, after it
is true then the block is executed until check the condition, if it is true the
the condition becomes false. body is executed until the condition
becomes false
3 Loop will not be executed if the Loop is executed at least once though
condition is false the condition is false.
4 Syntax: Syntax:
while (condition) do
{ {
Statements; Statements;
} }while(condition);

17. Give the syntax of for loop.


The looping statements are used to execute the set of statements repeatedly until
the condition becomes false.
for (initialize variable; condition ; increment/decrement)
{
statements ;
}

5
18. What do you mean by conditional operator? Give syntax.
Conditional operator is used to check the condition without using if statement. The
syntax is condition ? expression 1 : expression 2;
If the condition is true expression1 is executed otherwise expression2 is evaluated.

19. What is a ternary operator? Give an example.


Conditional operator is used to check the condition without using if statement. The
syntax is Condition ? Expression 1 : Expression 2;
If the condition is true expression1 is executed otherwise expression2 is evaluated.

20. Write a program to print the even numbers from 1 to 100.


#include<stdio.h>
main()
{
int i=2;
while (i<=100)
{
printf(“%d”,i);
i=i+2;
}
}

Part-C

1. Explain the structure of C Program in detail with an example.


2. Write in detail about constants and its classification.
3. Write in detail about various data types present in C Language, with a suitable example.
.4. Write a c program to calculate the energy bill, read starting and ending reading
No of units consumed rate (rs)
200-500 3.50
100-200 2.50
<100 1.50
5. Explain the various operators in c with one example for each operator.
6. Write a c program to calculate the students mark details with the following conditions given
below:
Range of average class
>=75 distinction
>=60 and < 75 first
>=50 and <60 second
<50 fail

7. Differentiate the formatted and unformatted Input / Output function present in C Language
and also explain with an example

6
8. Explain about various looping statements in C. Explain with syntax and example.
9. a. Write a program to reverse a given number.
b. Write a program to print prime numbers from 1 to 100.
10. Write a program to solve the following quadratic equation Ax 2 + Bx + C = 0.
11. Write a program to read a list of n elements and find the maximum and minimum without
using array.
12. a. Write a program to find whether the given number is palindrome or not.
b. Write a program to print the Fibonacci series up to 100.
13. Write a program to evaluate the following series
x - x 3 / 3! + x 5 / 5! - x 7 / 7! + ……….
14. Write a program to calculate the sum of remainders obtained by dividing with modular
division operation by 2 on 1 to 9 numbers.
15. How does switch statement differ from if statement? Explain with example.
16. Write a C program to convert the number of years represented by an integer into the
following units of time: a. Minutes, b. Hours, c. Days, d. Months, e. seconds
Use switch() statement.
17. Describe the various operators present in C Language.
18. Explain in detail about the operator precedence and there associatively.
19. Discuss in detail about conditional statement present in C Language with a suitable
example.
20. Create a C- Program which finds the greatest of three numbers using “if” statement.
21. Write a C- Program which finds the greatest of three numbers using the “conditional
operator”.
22. Write a C Program for finding the grade of students with a “switch case”.
23. Write a C Program to find the sum of n numbers using “while” or “do-while”.
24. Create a C Program to print the multiplication table of specified size using “for” statement.
25. Write a C Program to find the Armstrong number.
26. Write a C Program to find the Palindrome number.
27. Write a C Program to find the Factorial of a given number.
28. Write a C Program to find the number of digits in a given number.

Answers: Part-A
1. a 2.a 3.d 4.a 5.b 6.d 7.c 8.b 9.c 10.a 11.b 12.b 13.c 14.b 15.a 16.b 17.b
18.a 19.d 20.c 21.a 22.c

Unit- 2 Array, Function and String

Part-A
1. What will happen if in a C program you assign a value to an array element whose subscript
exceeds the size of array?

A. The element will be set to 0.

B. The compiler would report an error.

7
C. The program may crash if some important data gets overwritten.

D. The array size would appropriately grow.

2. What does the following declaration mean?


int (*ptr)[10];

A. ptr is array of pointers to 10 integers

B. ptr is a pointer to an array of 10 integers

C. ptr is an array of 10 integers

D. ptr is an pointer to array

3. In C, if you pass an array as an argument to a function, what actually gets passed?

A. Value of elements in array

B. First element of the array

C. Base address of the array

D. Address of the last element of array

4. The keyword used to transfer control from a function back to the calling function is

A. switch B. goto

C. go back D. return

5. How many times the program will print "C program" ?

#include<stdio.h>

int main()
{
printf("C program");
main();
return 0;
}

A. Infinite times B. 32767 times

8
C. 65535 times D. Till stack overflows

6. What will be the output of the program?

#include<stdio.h>

int main()
{
int fun();
int i;
i = fun();
printf("%d\n", i);
return 0;
}
int fun()
{
_AX = 1990;
}

A. Garbage value B. 0 (Zero)

C. 1990 D. No output

7. What will be the output of the program?

#include<stdio.h>
int reverse(int);

int main()
{
int no=5;
reverse(no);
return 0;
}
int reverse(int no)
{
if(no == 0)
return 0;
else
printf("%d,", no);
reverse (no--);
}

A. Print 5, 4, 3, 2, 1 B. Print 1, 2, 3, 4, 5

9
C. Print 5, 4, 3, 2, 1, 0 D. Infinite loop

8. If the two strings are identical, then strcmp() function returns

A. -1 B. 1

C. 0 D. Yes

9. How will you print \n on the screen?

A. printf("\n"); B. echo "\\n";

C. printf('\n'); D. printf("\\n");

10. The library function used to find the last occurrence of a character in a string is

A. strnstr() B. laststr()

C. strrchr() D. strstr()

11. Which of the following function is used to find the first occurrence of a given string in another string?

A. strchr() B. strrchr()

C. strstr() D. strnset()

12. Which of the following function is more appropriate for reading in a multi-word string?

A. printf(); B. scanf();

C. gets(); D. puts();

13. What will be the output of the program?

#include<stdio.h>
int main()
{
int fun(int);
int i = fun(10);
printf("%d\n", --i);
return 0;
}
int fun(int i)

10
{
return (i++);
}

A. 9 B. 10

C. 11 D. 8

14. What will be the output of the program?

#include<stdio.h>

int main()
{
int i=1;
if(!i)
printf("IndiaBIX,");
else
{
i=0;
printf("C-Program");
main();
}
return 0;
}

A. prints "IndiaBIX, C-Program" infinitely

B. prints "C-Program" infinetly

C. prints "C-Program, IndiaBIX" infinitely

D. Error: main() should not inside else statement

15. What will be the output of the program?

#include<stdio.h>
#include<string.h>

int main()
{
printf("%d\n", strlen("123456"));
return 0;
11
}

A. 6 B. 12

C. 7 D. 2

16. What will be the output of the program ?

#include<stdio.h>

int main()
{
printf(5+"Good Morning\n");
return 0;
}

A. Good Morning B. Good

C. M D. Morning

17. What will be the output of the program if the array begins at address 65486?

#include<stdio.h>
int main()
{
int arr[] = {12, 14, 15, 23, 45};
printf("%u, %u\n", arr, &arr);
return 0;
}

A. 65486, 65488 B. 65486, 65486

C. 65486, 65490 D. 65486, 65487

18. What will be the output of the program if the array begins 1200 in memory?

#include<stdio.h>
int main()
{
int arr[]={2, 3, 4, 1, 6};
printf("%u, %u, %u\n", arr, &arr[0], &arr);
return 0;
}

A. 1200, 1202, 1204 B. 1200, 1200, 1200

12
C. 1200, 1204, 1208 D. 1200, 1202, 1200

19. Which of the following statement is correct?

A. strcmp(s1, s2) returns a number less than 0 if s1>s2

B. strcmp(s1, s2) returns a number greater than 0 if s1<s2

C. strcmp(s1, s2) returns 0 if s1==s2

D. strcmp(s1, s2) returns 1 if s1==s2

20. What will be the output of the program if the array begins at 65472 and each integer occupies
2 bytes?
#include<stdio.h>

int main()

{ int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0};

printf("%u, %u\n", a+1, &a+1);

return 0; }

A. 65474, 65476 B. 65480, 65496

C. 65480, 65488 D. 65474, 65488

21. If a Storage class is not mentioned in the declaration, then default storage class is

A. Automatic B. static

C. external D. None of the above

22. What will be the output of the program ?

#include<stdio.h>
#include<string.h>
int main()
{
char str[] = "12345\0\abcdef\0";
printf("%s\n", str);
return 0;
}

A. abcdef B. 12345

13
C. 12345 abcdef D. 12345\0abcdef

23. What will be the output of the program ?

#include<stdio.h>
int main()
{
char str = "C program";
printf("%s\n", str);
return 0; }

A. Error B. C program

C. Base address of str D. No output

24. What will be the output of the program ?

#include<stdio.h>
#include<string.h>
int main()
{
printf("%c\n", "abcdefgh"[4]);
return 0;}

A. Error B. d

C. e D. abcdefgh

25. An external variable is one

A. Which is globally accessible by all functions

B. Which is declared outside the body of any function

C. Which resides in the memory till the end of the program

D. All of the above

Part-B

1. Define user defined function.

User defined functions are self-contained blocks of statements which are written by the user to
compute or perform a task. They can be called by the main program repeatedly as per the requirement.

2. List any four library functions and its use.

14
• getchar() returns the next character typed on the keyboard
• putchar() outputs a single character to the screen
• strcat() concatenates a copy of str2 to str1
• strcmp() compares two strings

3. Differentiate between library function and user defined function.

Predefined functions are the functions which are already defined and stored in certain header
files. Such as scanf() printf() are predefined.

User defined functions are the functions written by user (programmer) when there is no suitable
library function available to fulfil his/her logical requirement.

4. Differntiate between call by value and call by reference

The arguments passed to function can be of two types


1. Values passed
2. Address passed
The first type refers to call by value (pass by value) and the second type refers to call by
reference (pass by reference).Let's say we have an integer variable named x.
A call to a function by value using x means (a copy of) the value that x stores is passed in the
function call and no matter what the function does with that value, the value stored in x remains
unchanged.

A call to a function by reference using x means a reference (also called a pointer or alias) to the
variable x is passed in the function call and so any changes the function makes using this reference
will actually change the value stored in x.

Call by value passes the copy of the variable to the function that processes it whereas call by reference
passes the memory reference of the variable (pointer) to the function.

5. What is recursion?

A function that calls itself is known as recursive function and the process of calling function itself
is known as recursion in C programming.

Example

void recurse()

{ recurse(); /* Function calls itself */ }

int main()

{ recurse(); /* Sets off the recursion */

return 0; }

6. Define an array

15
An array is a collection of same type of elements which are stored under a common name.

The following illustrates the typical syntax of declaring an array:


data_type array_name[size];
For example, to declare an array of integers with size of 10, you can do as follows:
int a[10];

7. List out the types of arrays

Arrays can of following types:


1. One dimensional (1-D) arrays or Linear arrays
2. Multi dimensional arrays

a. Two dimensional (2-D) arrays or Matrix arrays


b. Three dimensional arrays

1. One dimensional (1-D) arrays or linear arrays:


In it each element is represented by a single subscript. The elements are stored in consecutive
memory locations. E.g. A [1], A [2], ….., A [N].

2. Multi dimensional arrays:


(a) Two dimensional (2-D) arrays or Matrix arrays:
In it each element is represented by two subscripts. Thus a two dimensional m x n array A has m
rows and n columns and contains m*n elements. It is also called matrix array because in it the
elements form a matrix. E.g. A [2] [3] has 2 rows and 3 columns and 2*3 = 6 elements.

(b) Three dimensional arrays:


In it each element is represented by three subscripts. Thus a three dimensional m x n x l array A
contains m*n*l elements. E.g. A [2] [3] [2] has 2*3*2 = 12 elements.

8. . Define storage class

A storage class defines the scope (visibility) and life time of variables and/or functions within a C
Program.There are following storage classes which can be used in a C Program

• auto
• register
• static
• extern

9. Differentiate between function definition and declaration

void functionName(int x, double y...); //declaration

void functionName(int x, double y...)//function definition { ...; //operators; }

Declaration of a function: The declaration gives a lot of information about the function. One, it tells it
the return type. Two, it tells it how many parameters there are, and what their types are.

16
Definition of a function: The definition tell what the function does

10. What is static function?

In C, functions are global by default. The “static” keyword before a function name makes
it static. For example, below function fun() is static.

static int fun(void)

printf("I am a static function ");

Unlike global functions in C, access to static functions is restricted to the file where they are
declared. Therefore, when we want to restrict access to functions, we make them static. Another reason
for making functions static can be reuse of the same function name in other files.

11. Give an example for initialization of an array

Initializing of array is very simple in c programming. The initializing values are enclosed
within the curly braces in the declaration and placed following an equal sign after the array name.
Here is an example which declares and initializes an array of five elements of type int. Array can
also be initialized after declaration. Look at the following C code which demonstrates the
declaration and initialization of an array.

int myArray[5] = {1, 2, 3, 4, 5}; //declare and initialize the array in one statement
int studentAge[4];
studentAge[0]=14;
studentAge[1]=13;
studentAge[2]=15;
studentAge[3]=16;

12. What is difference between strcpy()&strncpy() function?

Strcpy() is meant to copy only null-terminated strings. It is probably implemented to copy every
byte until it encounters a #0.
strncpy() copies n bytes and it adds null termination at the end of the target string .

13. What do you understand by 2-D arrays?

Two-dimensional arrays, the most common multidimensional arrays, are used to store
information that we normally represent in table form. Two-dimensional arrays, like one-dimensional
arrays, are homogeneous. This means that all of the data in a two-dimensional array is of the same type.

17
Syntax: Array Name[row][column]

Examples of applications involving two-dimensional arrays include:

• Seating plan for a room (organized by rows and columns)


• Monthly budget (organized by category and month), and
• Grade book where rows might correspond to individual students and columns to student
scores
14. Wha is NULL character? Why it’s important?

The NULL character (\0) in c can be used to mark the end of a string. For Instance, the printf()
puts the next character on the screen when the NULL character is encountered. Also, NULL character
always returns FALSE in a logical test.

15. What is void function?

Void is a value of a function type that means nothing is returned. A void function has a heading
that names the function followed by a pair of parentheses. The function identifier/name is preceded by
the word void. The parameter list with the corresponding data type is within the parentheses. The body
of the function is between the pair of braces.

Here is the syntax template of a void function prototype:

void functionName(DataTypeOfParameterList);

16. What is the difference between NULL '\0' and 0?

null(\0) is used for termination of string. It means each and every string ended with \0 while 0 is
a number. It represents an integer one less than 1. It is usable in all integer expressions, except as a divisor.

17. List out any four string manipulation functions.

Function Work Of Function

strlen() Calculates the length of string

strcpy() Copies a string to another string

strcat() Concatenates(joins) two strings

strcmp() Compares two string

strlwr() Converts string to lowercase

strupr() Converts string to uppercase

18. What is the difference between string constant and character constant?

A character type constant is a character, a char, while a string type is an array of characters. The
character type constant is one character and is delimited by single quotes. The string type constant is zero
or more characters and is delimited by double quotes.

18
21. Why do we need function prototypes?

A function prototype is basically a definition for a function. It is structured in the same way that
a normal function is structured, except instead of containing code, the prototype ends in a semicolon.
Normally, the C compiler will make a single pass over each file you compile. If it encounters a call to a
function that it has not yet been defined, the compiler has no idea what to do and throws an error. This
can be solved in one of two ways.
The first is to restructure your program so that all functions appear only before they are called in
another function.
The second solution is to write a function prototype at the beginning of the file. This will ensure that the
C compiler reads and processes the function definition before there's a chance that the function will be
called.

Part-C

1. Write a program to read 10 integers in an array and sort them in ascending and descending order

2. Write a program to calculate average temperature of five days using functions

3. Write a program to extract a substring from a specified position containing a specified number of
characters from an input string.

4. Write a program to find minimum and maximum element of an array.

5. Write a program to count frequencies of elements in an array.

6. Write a program to find multiplication of two matrices.

7. Write a program to check whether a given number is palindrome or not using function.

Answers: (Part-A)

1. C 2. B 3. C 4. D 5. D 6. C 7. D

8. C 9. D 10. C 11. C 12. C 13. A 14. B

15. A 16. D 17. B 18. B 19. C 20. B 21. A

22. B 23. A 24. C 25. D

Unit-III Pointers
Part-A

1. Which is the correct way to declare a pointer?

19
a. int *ptr; b. int ptr*; c. * int ptr; d. int_ptr x;

2. What will be the result of the following program?

int num,*p;
num=100;
p=&num;
printf("%d",*p);

a.100 b. Address of ‘num’ c. 2293528 d. none of them.

3. What will be the result of the following program?

int x[]={12,13,15,16};
int *p;
p=x;
p+=3;
printf("%d" ,*p);

a.12 b. 12,13,15 c.16 d. error

4. What will be the result of the following program?


int m=200;
int *p1=&m;
int **p2 =&p1;
printf("%d",**p2);

a. Error b. 200 c. Address of ‘m’ d. Address of ‘p1’

5. What is size of generic pointer in c?


a. 0 b. 1 c.2 d. Null
6. Is the following statement is a

int (*x) [10];

a. Declaration b. Definition c. error d. none of them.

7. What is (void*)0?
a. NULL pointer b. Void pointer c.Error d. None of above

8. What will be the result of the following program?

Int i=3, *j, k;


J=&I;

20
Printf(“%d \n”, i**j*i+*j);

a.27 b.30 c.9 d.3

9. What will be the result of the following program?

char str[20] = "Hello";


char *const p=str;
*p='M';
printf("%s \n", str);

a.Hello b. HMello c.Mello d. MHello

10. What will be the result of the following program?

char *p;
p="hello";
printf("%s\n", *&*&p);
a. llo b. hello c. ello d. h

11. What will be the result of the following program?

int m[2];
*(m+1)=300;
*m=*(m+1);
printf("%d", m [0]);

a.3 b.300 c.0 d.301

12. What will be the result of the following program?

int m[2];
int *p =m;
m[0]=100;
m[1]=200;
printf("%d %d", ++*p, *p);

a. 100 200 b.100 101 c.101 100 d.0 1

13. What will be the result of the following program?

int a=8,b=2,c,*p;
c=(a=a+b,b=a/b,a=a*b,b=a-b);
p=&c;
printf ("\n %d",++*p);

21
a. The value *p is 46. b. The value *p is 48.
c. The value *p is 56. d. The value *p is 40.

14. What will be the result of the following program?

static char a[]="BOMBAY";


char *b="BOMBAY";
printf("\n %d %d", sizeof(a),sizeof(b));

a. 7 4 b. BOMBAY c. 5 5 d. None of them.

15. What will be the result of the following program?

int arr[]={0,1,2,3,4};
int i, *ptr;
for(ptr=&arr[0];ptr<=&arr[4];ptr++)
printf("%d", *ptr);

a. 0 b.5 6 7 8 c.0 1 2 3 4 d.1 2 3 4

PART-B

1. What is pointer: How to access a variable through its pointer with example?

Pointer is a variable, which is stores the address of another variable.


To determine the address of a variable or the content of variable,

C permits us to use two special operators:


& - is address of operator (or) direction operator
* - is content of operator (or) indirect operator

1 - int t, b, *a;
2 - t=5;
3 - a=&t;
4 - b=*a;

1st line - t and b as integer variable, *a pointer variable


2nd line - assigns the value of 5 to the variable t
3rd line – assigns the address of variable, t to the pointer variable a
4th line – the content of the pointer variable a is assigned to b hence value of b=5;

2. What are the features of pointers?


22
• Pointers save the memory space
• Execution time which pointer is faster because data is manipulated with the
address.
• The memory is accessed efficiently with the pointer (Dynamically memory is
allocated)
• Pointers are used with data structures. They are useful for representing two and
multi dimensional arrays.

3. What is pointer to a pointer?

If a pointer variable points another pointer value. Such a situation is known as a pointer
to a pointer.
Example:
int *p1,
**p2,
v=10;P1=&v; p2=&p1;
Here p2 is a pointer to a pointer.

4. What is difference between array and pointer?

Array

• Array allocates space automatically.


• Arrays is a collection of similar datatype.
• It cannot be resized
• It cannot be reassigned.
• Size of (array name) gives the number of bytes occupied by the array.

Pointer

• Explicitly assigned to point to an allocated space.


• Pointers are used to manipulate data using the address.
• It can be sized using realloc() 3-pointer can be reassigned.
• Sizeof (p) returns the number of bytes used to store the pointer variable p.

5. What is a NULL pointer?

Null pointer is a pointer that is pointing nothing.


Examples :
int *ptr=(char *)0;
float *ptr=(float *)0;

6. What is a pointer value and address?

23
A pointer value is a data object that refers to a memory location. Each memory location
is numbered in the memory. The number attached to a memory location is called the
address of the location.

7. What is the function of a pointer variable? What are its uses?

Pointer variable are defined as variables that contain the memory addresses of data or
executable code.
Uses:
• Accessing array element.
• Passing argument to function by reference.
• Passing arrays and strings to function.
• Creating data structures such as linked list, trees, graphs, and so on.

8. Explain the difference between the address operator ‘&’ and bitwise operator ‘&’ with
example?
The bitwise logical operator and (&) calculates the bitwise logical and of two integral
values. It is a binary operator.
The address of (&) operator returns the address of the value to its right. It is a unary
operator.
9. Why addition of two pointers is impossible?

The pointer holds address of another variable. Hence, addition of addresses is not
possible.
10. Explain effect of (++) and (- -) operator with pointer of all data type?

The (++) increment operator when applied with pointer it indicates next memory location
of its type. When (--) decremented it indicates previous memory location of its type.

11. What are difference between call by value and call by reference?

Call by value: When values of built in types are passed as arguments to a function. It is
known as Call by value. The changes made to formal parameters in the called function are
not reflected in the actual arguments class.

Call by Reference: In this approach, an object is passed as an argument, which is assigned


to an object reference are directly reflected to actual argument.

PART-C

1. Explain the difference between an array of pointers and pointers to array?


2. How can a function return a pointer to its calling function?
3. What are the advantages of using pointer? How are pointers declared and
initialized?
4. How the value of variable is accessed using pointers?

24
5. Explain array of pointer in detail?
6. Briefly explain about

i) Structures and pointers


ii) Pointers to functions
iii) Arrays and pointers

7. Give the features of pointers and explain the effect of ++ and – operator with
pointers of all data types?
8. Write a program to swap 2 numbers using pointers.
9. Program for finding the largest and smallest element in the list using pointers.
10. What do you understand by a pointer to a pointer? With suitable example.
11. Explain call by value in detail.
12. Explain call by reference in detail.
13. Demonstrate how array can be accessed using pointer syntax.
14. Write a function to convert Fahrenheit temperature to centigrade temperature call
the function using function pointer.
15. Write a program to get five subject marks using integer array, pass the array to a
function calculate total and aggregate.

Answers – (Part-A)

1.a 2.a 3.a 4.b 5.c 6.a 7.a 8.b 9.c 10.b 11.b 12.b 13.a 14.a 15.c

UNIT-4 STRUCTURE AND UNION


Part-A

1.A ____ is a collection of data items under one name in which the items share the same storage.
a) Structure b) Union c)Array d)Files
2.. main()

{
struct
{
int i;
}xyz;
(*xyz)->i=10;
printf("%d",xyz.i);
}
What is the output of this program?

a) program will not compile b) 10 c) 15 d) address of I

3. The link between a member and a variable is established using the ______ operator.
a) Member b) Pointer c) Relational d) Bitwise
25
4. Which one of the following is not valid
a) struct keyword is used to define structure template.
b) The order of values enclosed in braces must match the order of members in structure
definition
c) The uninitialized members will be assigned default values.
d)We can initialize individual members inside the structure template.

5. Accessing structure member using pointer is called_____ method


a) dot notation b) Indirection notation c)Selection notation d)

6. The ____ can be used to create a synonym for a previously defined data type
a) Struct b) Union c)Array d)Files

7. The structure is a ______ data type


a) Build in data b) Pointer c) Array d) User defined

8. What will be the output of the program ?

#include<stdio.h>

int main()
{
union a
{
int i;
char ch[2];
};
union a u;
u.ch[0]=3;
u.ch[1]=2;
printf("%d, %d, %d\n", u.ch[0], u.ch[1], u.i);
return 0;
}

a. 3, 2, 515 b. 515, 2, 3

c. 3, 2, 5 d. 515, 515, 4
9.What will be the output of the program in 16 bit platform (Turbo C under DOS) ?

#include<stdio.h>

int main()
{
struct value
{
int bit1:1;
int bit3:4;
int bit4:4;
26
}bit;
printf("%d\n", sizeof(bit));
return 0;
}

a. 1 b. 2

c. 4 d. 9

10. A structure is a data type in which

a) Each element must have the same data type


b) Each element must have pointer data type only
c) Each element may have different data type
d)No element is defined

11. The _____ operator is used to access structure members


a) . b)* c)[ ] d)&

12. If one or more members of the structure are pointer to the same structure, the structure is known
as
a) Nested structure b) Invalid structure c)Self referential d)Inner structure

13. Point out the error in the program?

struct emp
{
int ecode;
struct emp *e;
};

a Error: in structure declaration

B. Linker Error

C. No Error

D. None of above

14 Point out the error in the program?

#include<stdio.h>

int main()
{
struct a
{

27
float category:5;
char scheme:4;
};
printf("size=%d", sizeof(struct a));
return 0;
}

A. Error: invalid structure member in printf

B. Error in this float category:5; statement

C No error

D None of above

15. Which of the following statements correct about the below code?
maruti.engine.bolts=25;
A. Structure bolts is nested within structure engine.

B. Structure engine is nested within structure maruti.

C. Structure maruti is nested within structure engine.

D. Structure maruti is nested within structure bolts.

Part-B

1. What is a structure in ‘c’? How is it declared?


A structure is a single entity representing a collection of data items of different data types.
It is a method for holding data of different types, using structure logically related data items
are grouped.
Syntax:
Struct structure_name;

2. What is the use of struct keyword?


The keyword struct tells the compiler that it is a struct data type. It is used to declare a
structure to hold the details of the structure elements or members.

3. How are structure elements stored in memory?


Structure elements are always stored in contiguous memory locations. We need to
specify both the structure name and the member name when accessing the information stored
in a structure.

4. What is nested structure?


Nested structure means structure within structure (i.e.,) if a structure contains more than
one structure as its member, it is known as nested structure.

28
5. How nested structure is declared?
Struct pay
{
Char name;
Char dept;
Int bp;
Struct inner
{
Int da;
Int ta;
Int hra;
}
Allowance;
}
employee;

6. How are array of structure variable defined?


We can declare an array of structures, each element of the array representing a structure
variable.
Eg:
struct class student[100];

7. How are structure elements assessed using pointer? Which operator is used?
The pointer variables contains the address of the separate data type ,the structure
elements assessed using pointer variable as follows:
Data_type * pointer_name;
The operator * is used for accessing structure.

8. What are the features of structure?

A structure is a single entity representing a collection of data items of different data


types.It have a declaration followed by definition.Structure contains bit fields,the members and their
data types are known at the time of declaration.

9. How the user defined data types are defined?

Enumerated data type is an user defined data type.Enum is a keyword,which is used for
declaring enumeration types.we can create our own data type using enum and we can define
values,the variables of the data types holds

Eg: enum week { mon,tues,.........,sun };

10.What is the importance of bit fields?

Bit fields are used to hold data items.It provides exact amount of bits required for
storage of values,to hold the information.The Bit field main intension is to reduce the memory
consumption.
29
11.How do bit fields save memory space?

In bit fields the variables that we use occupy a minimum of one byte for char and
two byte for integer.Instead of using complete integer if bits are used memory space can be saved.

12. What is enumerated data type?

Enumerated data type is an user defined data type.Enum is a keyword,which is used for
declaring enumeration types. We can create our own data type using enum and we can define
values,the variables of the data types holds

Eg: enum week { mon,tues,.........,sun };

13. What is union?

Union is similar to structure except in terms of storage and therefore it has the same syntax
as structure. Union can contain a number of members like structure but it holds only one object at a
time.

14. How is data stored in union?

The compiler allocates storage that is large enough to hold the largest variable type in the
union. All the variables declared in the union share the same address.

15. What is typedef?

Typedef is a keyword used to assign alternative names to the existing types. It helps to
declare user-defined identifiers that can be used in place of type specifiers such as int,char etc.

Part-C

1. Create structure called time_struct containing three memebers integer hour,minute and
second.Develop a program that would assign values to the memebers and display the
time in the following format 16:40:51 (S)
2. Describe with examples, the different ways of assigning values to structure memebers. (C)
3. Illustrate the cocept of nested structure with suitable syntax and example. ( C)
4. Describe three different approaches that can be used to pass structures as function
arguments. (C)
5. How the concept of union is differs from structure.Give examples for union. (K)
6. Exaplain about the steps, invovlved in defining and accessing structure memebers. (K)
7. Create a structure named date containing three integer memebers day,months and year.
Develop an intereactive modular program to perform the following tasks:
i ) To read data into structure memebers by function

30
ii) To validate the date entered by a function.( Example invalid data : 31,4,2002-April
has only 30 days, 29,2,2002- 2002 is not leap year) (S)
8. Create an union called cricket that will describe the following information:
i) player name,ii)team name,iii)bating average
using cricket,declare an array player with 20 elements and write a program to read the
information about all 20 players and print a team-wise list. (S)
9. Create a structure that can describe an hotel. It should have members that include the
name,address,grade,room charge.
write a functions to perform the following operations:
a) To print out hotels of given grade in order of charges.
b) To print out hotels with room charges less than given value. (S)
10. Explain in detail about arrays of structure with suitable examples. (C)

Answers ( Part-A )

1. B 2. A 3. A 4. D 5. C 6. A 7. D 8. A 9. B 10. C 11. A 12. C 13. C 14. B 15. B

Unit-5 (Files, Dynamic Memory Allocation, Preprocessor Directive)

Part-A

1. File manipulation functions in C are available in which header file?


a. stdio.h b. stdlib.h c. string.h d.stdarg.h
2. File is a collection of
a. Records b. Fields c. Bits d. Bytes
3. Which of the following mode is used for appending a file
a. a+ mode b. w+ mode c. r mode d. r+ mode
4. Which of the following function returns zero if no error occurs during the execution file program
a. ferror(fp) b. feof() c. fseek() d.rewind()
5. Which of the following function is used to get the current file position of the file represented by
the file pointer?
a. ftell(fp) b. fseek(fp) c. rewind(fp) d. feof(fp)
6. Which of the following function is used to read a character from the file
a. getchar() b. gets() c. getc()d. getch()
7. Which of the following function is used to write a character into a file
a. putc() b. putchar() c. putch() d. puts()
8. fseek(fp,0,0) will bring the file pointer to the ---------of the file
a. beginning b. end c. middle d. none of the above
9. Which of the following function bring the file pointer to the beginning of the file
a. fseek() b.ftell() c.rewind() d.feof()
31
10. What will be the output of the program?
#include<stdio.h>
#define MAN(x, y) ((x)>(y)) ? (x):(y);
int main()
{
int i=10, j=5, k=0;
k = MAN(++i, j++);
printf("%d, %d, %d\n", i, j, k);
return 0;
}
a) 12, 6, 12 b) 11, 5, 11
c) 11, 5, Garbage d) 12, 6, Garbage

11. What will be the output of the program?


#include<stdio.h>
#define SQUARE(x) x*x
int main()
{
float s=10, u=30, t=2, a;
a = 2*(s-u*t)/SQUARE(t);
printf("Result = %f", a);
return 0;
}
a) Result = -100.000000 b) Result = -25.000000
c) Result = 0.000000 d) Result = 100.000000

12. What will be the output of the program?


#include<stdio.h>
#define SQR(x)(x*x)
int main()
{
int a, b=3;
a = SQR(b+2);
printf("%d\n", a);
return 0;
}
a) 25 b) 11
c) error d) garbage

13. What will be the output of the program?


#include<stdio.h>
#define JOIN(s1, s2) printf("%s=%s %s=%s \n", #s1, s1, #s2, s2);
int main()
{
char *str1="India";
char *str2="BIX";
JOIN(str1, str2);
return 0;
}
a) str1=IndiaBIX str2=BIX b) str1=India str2=BIX
c) str1=India str2=IndiaBIX d) Error: in macro substitution

32
14. What will be the output of the program?
#include<stdio.h>
#define CUBE(x) (x*x*x)
int main()
{
int a, b=3;
a = CUBE(b++);
printf("%d, %d\n", a, b);
return 0;
}
a) 9, 4 b) 27, 4
c) 27, 6 d) error

15. What will the SWAP macro in the following program be expanded to on preprocessing? will the
code compile?
#include<stdio.h>
#define SWAP(a, b, c)(c t; t=a, a=b, b=t)
int main()
{
int x=10, y=20;
SWAP(x, y, int);
printf("%d %d\n", x, y);
return 0;
}
a) it compiles b) compiles with an warning
c) not compile d) compiles and print nothing

16. In which stage the following code


#include<stdio.h>
gets replaced by the contents of the file stdio.h
a) during editing b) during linking
c) during execution d) during preprocessing

17. #include is called


a) Preprocessor directive b) Inclusion directive
c) File inclusion directive d) None of the mentioned

18. C preprocessor is conceptually the first step during compilation


a) true b) false
c) Depends on the compiler d) Depends on the standard

19. Preprocessor feature that supply line numbers and filenames to compiler is called?
a) Selective inclusion b) macro substitution
c) Concatenation d) Line control

20. #include are _______ files and #include “somefile.h” ________ files.
a) Library, Library b) Library, user-created header
c) User-created header, library d) They can include all types of file

33
21. A preprocessor is a program
a) That processes its input data to produce output that is used as input to another program
b) That is nothing but a loader
c) That links various source files
d) All of the mentioned

22. What is the output of this C code?


#include <stdio.h>
void main()
{
#define max 37;
printf("%d", max);
}
a) 37 b) Compile time error
c) Varies d) Depends on compiler

23. What is the output of this C code?


#include <stdio.h>
void main()
{
#define max 37
printf("%d", max);
}
a) 37 b) Run time error
c) Varies d) Depends on compiler

24.What is the output of this C code?


#include <stdio.h>
void main()
{
#define const int
const max = 32;
printf("%d", max);
}
a) Run time error b) 32
c) int d) const

25. What is the output of this C code?


#include <stdio.h>
void main()
{
#define max 45
max = 32;
printf("%d", max);
}
a) 32 b) 45
c) Compile time error d) Varies

26. What is the output of this C code?


#include <stdio.h>
# define max

34
void m()
{
printf("hi");
}
void main()
{
max;
m();
}
a) Run time error b) hi hi
c) Nothing d) hi

27. What is the output of this C code?


#include <stdio.h>
#define A 1 + 2
#define B 3 + 4
int main()
{
int var = A * B;
printf("%d\n", var);
}
a) 9 b) 11
c) 12 d) 21

28. Which of the following Macro substitution are accepted in C?


a) #define A #define
A VAR 20
b) #define A define
#A VAR 20
c) #define #A #define
#A VAR 20
d) None of the mentioned

29. Comment on the following code?


#include <stdio.h>
#define var 20);
int main()
{
printf("%d\n", var
}
a) No errors, it will show the output 20
b) Compile time error, the printf braces aren’t closed
c) Compile time error, there are no open braces in #define
d) Both (b) and (c).

30. Which of the following properties of #define not true?


a) You can use a pointer to #define
b) #define can be made externally available
c) They obey scope rules
d) All of the mentioned

35
31. What is the advantage of #define over const?
a) Data type is flexible
b) Can have a pointer
c) Reduction in the size of the program
d) Both (a) and (c)

32. What is the output of this C code?


#include <stdio.h>
#define foo(x, y) x / y + x
int main()
{ int i = -6, j = 3;
printf("%d\n",foo(i + j, 3));
return 0;
}
a) Divided by zero exception b) Compile time error
c) -8 d) -4

33. DMA functions in C are available in which header file?


a. a. stdio.h b. stdlib.h c. string.h d.stdarg.h

34. In dynamic memory allocation the memory is obtained during

a.run time b.compile time c.none the above

3.malloc() function is used to

a.allocate memory space b.reallooate memory space c.release d.modify

35. calloc() function is used in memory space to

a.allocate b.reallocate c.modify d.delete

36.realloc()function is used in memory space to

a.allocate b.reallocate c.modify d.delete

37. free() function is used in memory space to

a.allocate b.reallocate c.modify d.delete

Part-B

36
1. Define File
File is a place on the disk, where the related data are stored. To store the data
into the disk and also keep the data permanently, we need a concept called files.

2. What does opening of a file mean? How is it performed?


To store the data in to secondary memory using files, we must create the file or
we have to open the already existing file.
Syntax for opening a file:
FILE *fp;
fp=fopen(“sample.txt”,”mode”);

3. What are the different modes of files?


r mode => Open the file for reading only
w mode => open the file writing only
a mode => open the file for appending or adding
r+ mode=> open for reading and writing
w+ mode=> open for reading and writing(overwriting)
a+ mode=> Open for reading and writing(append if file exists)

4. What is closing of a file? How is it accomplished in a program?


Opened file has to be closed after the operations are completed.
The syntax for closing the file
fclose (file pointer);

5. Write a program to open a file and write some text and close it.
#include<stdio.h>
int main(){
FILE *fp;
char ch;
fp=fopen("file.txt","w");
printf("\nEnter data to be stored in to the file:");
while((ch=getchar())!=EOF)
putc(ch,fp);
fclose(fp);
return 0;
}
6. Write a program to copy the content of one file into another file.
#include<stdio.h>
int main()
{
FILE *p,*q;
char file1[20],file2[20];
37
char ch;
printf("\nEnter the source file name to be copied:");
gets(file1);
p=fopen(file1,"r");
if(p==NULL)
{
printf("cannot open %s",file1);
exit(0);
}
printf("\nEnter the destination file name:");
gets(file2);
q=fopen(file2,"w");
if(q==NULL)
{
printf("cannot open %s",file2);
exit(0);
}
while((ch=getc(p))!=EOF)
putc(ch,q);
printf("\nCOMPLETED");
fclose(p);
fclose(q);
return 0;
}

7. What is the difference between w+ mode and a+ mode?


Both r+ and w+ we can read, write on file. But r+ does not truncate (delete) the
content of file as well it doesn’t create a new file, if such file doesn’t exits. In w+ mode
truncate the content of file as well as create a new file if such file doesn’t exist.
8. Why is it necessary to close a file during the execution of a program?

The fclose() function first flushes the stream opened by fopen() and then closes
the underlying descriptor. Upon successful completion this function returns 0 else end
of file (eof) is returned.

9. What is a preprocessor?
It is s program that processes our source program before compilation.The compiler
examines the preprocessor for any preprocessor directives. If there are any preprocessor
directives , appropriate actions are taken and then the source program is moved for
compilation.

10. Give the operations of preprocessor?


a) File inclusion
b) Macro substitution
c) Conditional inclusion
38
11. Give the rules for defining preprocessor.
a) Every preprocessor should begin with # symbol.
b) The preprocessor is always placed before main() function.
c) The preprocessor cannot have termination with semicolon.
d) There is no assignment operator in #define statement.
e) The conditional macro must be terminated (#ifdef, #endif)

12. Define Macro substitution and give its types.


Macro substitution is used to define symbolic constants in the source program. It is classified
in to i)Simple macro ii)Argumented macro iii)Nested macro

13. Define conditional inclusion.Give its types.


It is used to control the preprocessor with conditional statements. The types are #include,
#define, #ifdef, #else, #undef.

14. Write a program to print square and cube values using macro substitution.
#define sq(n) (n*n)
#define cube(n) (n*n*n)
#include <stdio.h>
main()
{ int a=5,b=3,s,c;
s=sq(a);
c=cube(b);
printf(“\nSquare of 5 is %d”,s);
printf(“\nCube of3 is %d”,c); }

15. List the various preprocessors.


#include, #define, # ifdef, #else, # undef

16. Define File inclusion preprocessor.


This is used to include an external file which contains functions or some other macro
definition to our source program.
syntax: #include<file name> #include “file name”
example: #include<stdio.h> #include ‘’loop.c”

17. Explain command line arguments.

To use command line arguments in your program, you must first understand the full
declaration of the main function. Main can accept two arguments: one argument is
number of command line arguments, and the other argument is a full list of all of the
command line arguments. The full declaration of main is,
int main ( int argc, char *argv[] )
The integer, argc is the argument count. It is the number of arguments passed into
the program from the command line, including the name of the program.
The array of character pointers is the listing of all the arguments. argv[0] is the name
of the program, or an empty string if the name is not available. After that, every
element number less than argc is a command line argument. You can use each argv
39
element just like a string, or use argv as a two dimensional array. argv[argc] is a null
pointer.

18. Discuss the use of command line arguments.


It is used to give the input data along the command name during the execution of the
program. For ex, c:\> ren abc.c def.c
Where ren is a command name which is used to rename the existing file. abc.c refers
source file and def.c refers the target file.

19. Explain the arguments which are possible to pass in main()


main() is possible to pass 3 arguments
1. argc: It is an integer and is the number of arguments passed to the function main()
2. argv: It is an array of strings.
3. argenv: It is also used as an array of strings. Each element of argenv[] holds a string and
it is of the form ENVVAR=value. Here ENVVAR is name of the environment variable, for
ex.PATH.

20. How does a C program come to know about command line arguments?

When we execute our C program, operating system loads the program into memory. In
case of DOS, it first loads 256 bytes into memory, called program segment prefix. This
contains file table, environment segment, and command line information. When we
compile the C program the compiler inserts additional code that parses the command,
assigning it to the argv array, making the arguments easily accessible within our C
program.

21. Define static memory allocation?

The process of allocating memory at compile time is called static memory allocation and the data
requirements are know exactly

22. Define dynamic memory allocation?

If memory is allocated during runtime it is called dynamic memory allocation

23. Write the syntax of calloc() function?

pointer variable=(data type*) calloc (n, size in bytes);

24. Define realloc function?

To alter the size of allocated memory the nrealloc() function is used.

25. What are the function available to allocate memory at runtime in c?

malloc(),calloc() are the two functions used to allocate memory at runtime.

26.Give the advantages of dynamic memory allocation?

40
The main advantage of using dynamic memory allocation is preventing the wastage of memory.
This is because when we use static memory allocation, a lot of memory is wasted because all the
memory allocated cannot be utilised. Thus dynamic memory allocation helps us to allocate memory
as and when required and thus saves memory.

Part-C

1. Two data files LADIES and GENTS contain sorted list of names of girls and boys in a class
respectively. Write a program to produce a third file STUDENTS which holds the merged
list of the two given files.
2. Write a program that copies one file to another, replacing all lower characters by their
upper case equivalents.
3. Explain the functions fread(),fwrite(),fopen(),fclose() with syntax and example.
4. A file contains information about the employees of an organization. The information
includes employee number, salary and age. Write a program to count the number of
records in that file and also print the employee numbers for those who are getting
salary less than Rs.4500 and aged more than 35.
5. Explain about file with its various functions.
6. Define macro. Explain its various types with example.
7. What is preprocessor? Explain #define, #include.
8. Explain command line arguments with example?
9. Write a program to print the sum of n numbers and passing the numbers through
command line.
10. Write a program to sort the given set of numbers and pass the numbers through
command line.
11. Illustrate with an example how command line arguments are used in program.
12. Write a Program to merge 2 files using command line arguments.
13. Write a Program to count the number of characters, words, sentences and lines in a file
using command line arguments.
14. Write a program using command line arguments to copy one file in to another.
15. Explain the DMA function in c with example?
16. Write a c program to allocate memory space and reallocate the existing memory by using
the appropriate DMA function.

Answer: 1. b, 2. a, 3. a, 4. a, 5. a, 6.c, 7.a, 8.a, 9.c, 10.a, 11.a, 12.b, 13.b, 14.c, 15.c, 16.d, 17.a, 18.a,
19.d, 20.d, 21.a, 22.b,23.a, 24.b, 25.c, 26.d, 27.b, 28.d, 29.a, 30.d, 31.a, 32.c

41
42

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy