You are on page 1of 9

PART A – 2 MARKS

1. What is an array?

An Array is a collection of similar data items, which are stored under a common name.
A value in an array is identified by Index.
Array is a derived data type. It is very effective when working with large number of
data of same data type or different data types. Array reduces the programming size or coding.

2. Write the limitations of getchar( ) and sacnf( ) functions for reading strings

getchar( )

To read a single character from stdin, then getchar() is the appropriate.

scanf( )

scanf( ) allows to read more than just a single character at a time.

3. What is the difference between scanf() and gets() function?

In scanf() when there is a blank was typed, the scanf() assumes that it is an end. gets() assumes the
enter key as end. That is gets() gets a new line (\n) terminated string of characters from the
keyboard and replaces the ‘\n’ with ‘\0’.

4. Why is it necessary to give the size of an array in an array declaration?

When an array is declared, the compiler allocates a base address and reserves enough space in the
memory for all the elements of the array. The size is required to allocate the required space. Thus,
the size must be mentioned.

5. What is meant by enumerated data type?

The ANSI provides user defined data type which is called enumerated data type ., i.e the
programmer can create their own data type and define what values the variables of these data types
can hold.
6. How are multi-dimensional arrays stored in C?

A 2-D array is an array of 1-D arrays and can be visualized as a plane that has rows and
columns. Each row is single dimensional array. A 3D array is an array of 2D arrays and can be
visualized as a cube that has planes. Each plane is 2D arrays.

7. How null character is represented in C ?

A character constant with ASCII value of zero is known as the null character and is written as ‘\0’.

8. Write a C program to find the length of the string ?

#include<stdio.h>

#include<conio.h>

#include<string.h>

main()

char s[]=”CSE”;

int len;

len=strlen(s);

printf (“The length of %s : %d”, s,len);

OUTPUT:

The length of CSE : 8

9. What is NULL string? What its length?

The length of a string can be stored implicitly by using a special terminating character; often
this is the null character (NULL-‘\0’), which has all bits zero. It have no limit.

10. What are the functions used to concatenate and reverse of strings?

Concatentation functions
strcat String Concatenation
Strrev
strncat Bounded String Concatenation

11. Write a c program to convert the string from lower case to upper case with out using string
Reverse:
function?

#include<stdio.h>

int main(){

  char s[20];

  int I,len;

  printf("Enter the string");

scanf("%s",s);

len =strlen(s);

   for(i=0;i<=len;i++)

           If (s[i] >=97 && s[i] <= 122)

            s[i]=s[i]-32;

 }

  printf("\nThe string in lowercase is->%s",s);

  return 0;

12. What are the classifications of Array?


Arrays can be classified into
One Dimensional Array
Two Dimensional Array
Multi dimensional Array

Unit IV – 2 marks

1. What is mean by user define functions?


The function defined by the users according to their requirements are called user-defined
functions. The users can modify the function according to their requirements.

2. Give the advantages of user-defined functions.

 The length of the source program can be reduced by dividing it into the smaller functions.
 The user-defined function can be used in many other source programs whenever necessary.
 reuse

3. What are actual and formal parameters?

Actual parameter:
The parameters in which are transferred from the calling function to the called
program.

Formal parameter:
The parameters are transferred from the called function to the calling program

4. Name the operators (&, *)

&- Address operators

* - Deferencing operator.

5. What are the advantages of using pointers?

A pointer provides the following advantages.

(i) Pointers are more compact and efficient code.

(ii) Pointers are used to pass information band and forth between function and its reference and its
reference point.

(iv) Pointers provide a way to return multiple data items from a function using its function
arguments.

6. What is the difference between the * and address of operator (.) ?


The indirection operators (*) returns the value of the address stored in a pointer. The address of
operator (&) returns the memory address of the variable.

7. What is null pointer ?

A pointer is said to be a null pointer when its right side value is 0.

8. What is pointer to pointer?

A variable that is a pointer to a pointer must be declared using additional indirection


operator symbols in front of the name.

int ** p;

Pointer is a variable that contains the address of the another variable.

9. What is meant by call by value and call by reference?

The process of passing the actual value of variables is known as “call by value”. The process
of calling a function using pointers to pass the addresses of variables is known as “call by reference”.
Unit V

PART A – 2 MARKS

1. What is structure?

A structure is a user defined data type which allows you to combine data items of
different kinds into a single unit. All the elements of a structure are stored at contiguous
memory locations. i.e., store heterogeneous data under unique name.

Keyword 'struct' is used to declare structure. The variables which are declared inside
the structure are called as 'members of structure'.

2. What is Union?

Union is user defined data type used to stored data under unique variable name at
single memory location. Union holds value for one data type which requires larger storage
among their members.

3. What are the differences between structure and union?

Structure Union

We can access all the members of Only one member of union can be accessed at
structure at anytime. anytime.

Allocates memory for variable which variable


Memory is allocated for all variables.
require more memory.

All members of structure can be


Only the first member of a union can be initialized.
initialized

'struct' keyword is used to declare


'union' keyword is used to declare union.
structure.

4. What are advantages of union over structures


Union save memory space because the size of the union is equal to its largest sized
member. The size of the structure is the sum of the sizes of all structure members. So
Structure occupies a large space. Union are useful when there is a need to use only one of its
member at a time, But structure is used when there is a need to use all its members in a
program.

5. What is storage class ? List its types?

Storage classes

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

6. What is auto storage class?

auto is the default storage class for all local variables.

Ex: auto int age;


This variable are private (local) to the function in which they are declared. If automatic
variables are not initialized they will contain garbage.

7. What is static storage class?

static is the default storage class for global variables. Static variables are initialized
only once, when the program is compiled.
Ex: static int count;

8. What is C Preprocessor?
It is a program that processes the source code before it process by compiler. The C
Preprocessor is not part of the compiler, but is a separate step in the compilation process. In
simplistic terms, a C Preprocessor is just a text substitution tool.

9. List out the various conditional directives.


1. #if
2. #ifdef
3. #ifdef
4. #elif
5. #elseif and
6. #endif

10. What are the different forms of macro substitution?


 Simple macro
 Argumented macro
 Nested macros

11. What are the classification of preprocessor directives?

 File Inclusion directives


 Macro substitution directives

PART – B

1. Write a C program to create and print the student database with the following fields :
no,name,m1,m2,m3,m4,m5,total and average. If the student has failed in any of the
subjects, assign FAIL else based on the average, assign first class with distinction or, first
class or second class.
2. Create a employee database with 4 employees using nested structure : no, name and
address. Let the nested structure be salary with fields basic,hra,da,ta and cca. Display the
details of employees with salary >6000.
3. Define a data type for storing complex numbers and implement addition, subtraction,
multiplication operations for the defined type.
4. Create a payroll application using structure with the following details :

DA= 15% of basic


HRA= 20% of basic
TA=18% of basic
Gross salary = basic + HRA + DA + TA
Deduction = PF + tax;
Net Salary =Gross Salary – Deduction

5. Write a C program using structure to print the details of book. Use array of structure

You might also like