Professional Documents
Culture Documents
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( )
scanf( )
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’.
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.
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.
A character constant with ASCII value of zero is known as the null character and is written as ‘\0’.
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
char s[]=”CSE”;
int len;
len=strlen(s);
OUTPUT:
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;
scanf("%s",s);
len =strlen(s);
for(i=0;i<=len;i++)
s[i]=s[i]-32;
}
return 0;
Unit IV – 2 marks
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
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
* - Deferencing operator.
(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.
int ** p;
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.
Structure Union
We can access all the members of Only one member of union can be accessed at
structure at anytime. anytime.
Storage classes
A storage class defines the scope (visibility) and life time of variables and/or
functions within a C Program.
auto
register
static
extern
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.
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 :
5. Write a C program using structure to print the details of book. Use array of structure