0% found this document useful (0 votes)
269 views

Interview Questions1

This document provides information to help prepare for an aerospace software firm interview. It includes topics like programming language concepts, testing skills, process skills, and avionics questions. Specifically, it discusses static variables in C, type casting, the C preprocessor, the purpose of the main function, differences between formal and actual arguments, differences between structures and unions, and C storage classes. Examples are provided to help explain some of the concepts.
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)
269 views

Interview Questions1

This document provides information to help prepare for an aerospace software firm interview. It includes topics like programming language concepts, testing skills, process skills, and avionics questions. Specifically, it discusses static variables in C, type casting, the C preprocessor, the purpose of the main function, differences between formal and actual arguments, differences between structures and unions, and C storage classes. Examples are provided to help explain some of the concepts.
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/ 54

Prepared by: Rana Mehul

E-mail: [email protected]

Increase Your Confidence


Before facing An
Aerospace Software
Firm’s Interview

Topics Included:
1. Programming Language Concepts
2. Testing skills (unit, S/w Integration, HSI
etc)
3. Process Skills (DO178B)
4. Avionics basis Questions
Prepared by: Rana Mehul
E-mail: [email protected]

Programming Language Concepts

1. What does static variable mean?

Answer: A local variable that does not cease to exist upon termination of the block
in which it can be accessed, but instead retains its most recent value until the next
execution of this block. It is strored in data segment.

A static variable behaves in a different manner depending upon whether it is a


global variablr or a local variable. A static global variable is same as an ordinary
global variable except that it cannot be accessed by other files in the same program /
project even with the use of keyword extern. A static local variable is different from
local variable. It is initialised only once no matter how many times that function in
which it resides is called. It may be used as a count variable.

Example:

void count(void) {
static int count1 = 0;
int count2 = 0;
count1++;
count2++;
printf("\nValue of count1 is %d Value of count2 is %d", count1,count2);
}
main()
{
count();
count();
count();
}

Output would be:


Value of count1 is 1 Value of count2 is 1
Value of count1 is 2 Value of count2 is 1
Value of count1 is 3 Value of count2 is 1

2. What is type casting?


Ans: Typecasting is making a variable of one type, such as an int, act like
another type, a char, for one single operation.

Implicit Casting (automatic transformation) works in a way that a variable


(operand) of data type that is smaller in length (than data type of second
variable) (operand), transforming internally to variable of data type with longer
number length.
Prepared by: Rana Mehul
E-mail: [email protected]
Explicit Casting (given transformation) of data types has higher priority then
automatic transformation. General declaration of explicit (given) cast (cast
operator):

(data_type) operand

Operand can be variable or phrase.

Example 1:
Consider the code:
float a = 5.25;
int b = (int)a; /*Explicit casting from float to int.
The value of b here is 5*/

Example 2:
Consider the code:
char c = ’A’;
int x = (int)c; /*Explicit casting from char to int.
The value of x here is 65: the ASCII code of ‘A’*/

3. What is Preprocessor? What will the preprocessor do for a program ?

Ans: The C preprocessor is a macro processor that is used automatically by the C


compiler to transform your program before actual compilation. It is called a macro
processor because it allows you to define macros, which are brief abbreviations for
longer constructs.

The C preprocessor provides four separate facilities that you can use as you see fit:

Inclusion of header files. These are files of declarations that can be substituted
into your program.
Macro expansion. You can define macros, which are abbreviations for arbitrary
fragments of C code, and then the C preprocessor will replace the macros with
their definitions throughout the program.
Conditional compilation. Using special preprocessing directives, you can include
or exclude parts of the program according to various conditions.
Line control. If you use a program to combine or rearrange source files into an
intermediate file which is then compiled, you can use line control to inform the
compiler of where each source line originally came from.

4. What is the purpose of main( ) function ?

Ans: The function main( ) invokes other functions within it.It is the first function to
be called when the program starts execution.
Prepared by: Rana Mehul
E-mail: [email protected]
 It is the starting function
 Recursive call is allowed for main( ) also.
 It has two arguments 1)argument count and 2) argument vector (represents
strings passed).

5. What is an argument? Differentiate between formal arguments and actual


arguments?

Ans: An argument is an entity used to pass the data from calling function to the
called function.

Formal arguments are the arguments available in the function definition.They are
preceded by their own data types.Actual arguments are available in the function
call.

The arguments listed in function definition are known as formal arguments. And
the arguments passed to function while invoking it, are known as actual
arguments.

For e.g:
-----------
int foo(int a, int b)
{
return (a+b);
}

int main(void)
{
int var1 = 10, var2 = 10;
int result;
result = foo(var1, var2);
return 0;
}

in the above case, var1 & var2 are actual arguments and "a" and "b" are formal
arguments.

6. Differentiate between a structure and a union


Ans:

Difference Between Stucture and Union :


Prepared by: Rana Mehul
E-mail: [email protected]

Structure Union

i. Access Members

We can access all the members of Only one member of union can be accessed

structure at anytime. at anytime.

ii. Memory Allocation

Allocates memory for variable which


Memory is allocated for all variables.
variable require more memory.

iii. Initialization

All members of structure can be Only the first member of a union can be

initialized initialized.

iv. Keyword

'struct' keyword is used to declare


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

v. Syntax

struct struct_name union union_name


{ {

structure element 1; union element 1;

structure element 2; union element 2;

---------- ----------

---------- ----------

structure element n; union element n;

}struct_var_nm; }union_var_nm;
Prepared by: Rana Mehul
E-mail: [email protected]

vi. Example

struct item_mst union item_mst


{ {

int rno; int rno;

char nm[50]; char nm[50];

}it; }it;

7. What are the different storage classes in C?


Ans:
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

auto - Storage Class

auto is the default storage class for all local variables.

{
int Count;
auto int Month;
}

The example above defines two variables with the same storage class. auto can only be
used within functions, i.e. local variables.

register - Storage Class

register is used to define local variables that should be stored in a register instead of
RAM. This means that the variable has a maximum size equal to the register size (usually
one word) and cant have the unary '&' operator applied to it (as it does not have a
memory location).
Prepared by: Rana Mehul
E-mail: [email protected]
{
register int Miles;
}

Register should only be used for variables that require quick access - such as counters. It
should also be noted that defining 'register' goes not mean that the variable will be stored
in a register. It means that it MIGHT be stored in a register - depending on hardware and
implimentation restrictions.

static - Storage Class

static is the default storage class for global variables. The two variables below (count and
road) both have a static storage class.

static int Count;


int Road;

{
printf("%d\n", Road);
}

static variables can be 'seen' within all functions in this source file. At link time, the static
variables defined here will not be seen by the object modules that are brought in.

static can also be defined within a function. If this is done the variable is initalised at run
time but is not reinitalized when the function is called. This inside a function static
variable retains its value during vairous calls.

void func(void);

static count=10; /* Global variable - static is the default */

main()
{
while (count--)
{
func();
}

void func( void )


{
static i = 5;
i++;
printf("i is %d and count is %d\n", i, count);
Prepared by: Rana Mehul
E-mail: [email protected]
}

This will produce following result

i is 6 and count is 9
i is 7 and count is 8
i is 8 and count is 7
i is 9 and count is 6
i is 10 and count is 5
i is 11 and count is 4
i is 12 and count is 3
i is 13 and count is 2
i is 14 and count is 1
i is 15 and count is 0

NOTE : Here keyword void means function does not return anything and it does not take
any parameter. You can memoriese void as nothing. static variables are initialized to 0
automatically.

Definition vs Declaration : Before proceeding, let us understand the difference between


defintion and declaration of a variable or function. Definition means where a variable or
function is defined in realityand actual memory is allocated for variable or function.
Declaration means just giving a reference of a variable and function. Through declaration
we assure to the complier that this variable or function has been defined somewhere else
in the program and will be provided at the time of linking. In the above examples char
*func(void) has been put at the top which is a declaration of this function where as this
function has been defined below to main() function.

There is one more very important use for 'static'. Consider this bit of code.

char *func(void);

main()
{
char *Text1;
Text1 = func();
}

char *func(void)
{
char Text2[10]="martin";
return(Text2);
}

Now, 'func' returns a pointer to the memory location where 'text2' starts BUT text2 has a
Prepared by: Rana Mehul
E-mail: [email protected]
storage class of 'auto' and will disappear when we exit the function and could be
overwritten but something else. The answer is to specify

static char Text[10]="martin";

The storage assigned to 'text2' will remain reserved for the duration if the program.

extern - Storage Class

extern is used to give a reference of a global variable that is visible to ALL the program
files. When you use 'extern' the variable cannot be initalized as all it does is point the
variable name at a storage location that has been previously defined.

When you have multiple files and you define a global variable or function which will be
used in other files also, then extern will be used in another file to give reference of
defined variable or function. Just for understanding extern is used to decalre a global
variable or function in another files.

File 1: main.c

int count=5;

main()
{
write_extern();
}

File 2: write.c

void write_extern(void);

extern int count;

void write_extern(void)
{
printf("count is %i\n", count);
}

Here extern keyword is being used to declare count in another file.

Now compile these two files as follows

gcc main.c write.c -o write

This fill produce write program which can be executed to produce result.
Prepared by: Rana Mehul
E-mail: [email protected]
Count in 'main.c' will have a value of 5. If main.c changes the value of count - write.c
will see the new value

8. What are the differences between malloc() and calloc()?

Ans: malloc() : malloc create the single block of given size by user
calloc() : calloc creates multiple blocks of given size
* Both return void pointer(void *)so boh requires type casting
examples:

For malloc()

int *p;
p=(int*)malloc(sizeof(int)*5)

Above syntax tells that malloc occupies the 10 bytes memeory and assign the
address of first byte to P

For calloc()

int *p;
p=(int*)calloc(5,sizeof(int)*5)

Above syntax tells that calloc occupies 5 blocks each of the 10 bytes memeory
and assign the address of first byte of first block to P

Also, malloc() takes only one argument i.e. size in bytes to be allocated while calloc()
takes two arguments viz., total number of data and size of each data.

Also, memory allocated by malloc() contains garbage values whereas memory


allocated by calloc() contains all zeros.

9. write a program for finding factorial; factorial using recursion


Ans:

#include<stdio.h>

long factorial(int);

main()
{
Prepared by: Rana Mehul
E-mail: [email protected]
int num;
long f;

printf("ENTER A NUMBER TO FIND FACTORIAL :");


scanf("%d",&num);

if(num<0)
printf("NEGATIVE NUMBERS ARE NOT ALLOWED");
else
{
f = factorial(num);
printf("%d!=%ld",num,f);
}
return(0);
}

long factorial(int n)
{
if(n==0)
return(1);
else
return(n*factorial(n-1));
}

10. Program for string reversal, String functions


Ans1:
#include<stdio.h>
#include<string.h>
main()
{
char str[50],revstr[50];
int i=0,j=0;
printf("Enter the string to be reversed : ");
scanf("%s",str);
for(i=strlen(str)-1;i>=0;i--)
{
revstr[j]=str[i];
j++;
}
revstr[j]='\0';
printf("Input String : %s",str);
printf("\nOutput String : %s",revstr);
getch();
}
Prepared by: Rana Mehul
E-mail: [email protected]

Ans2: #include<stdio.h>
#include<conio.h>
#include<string.h>

main()
{
char arr[100];

printf("Enter a string to reverse\n");


gets(arr);

strrev(arr);

printf("Reverse of entered string is \n%s\n",arr);

getch();
return 0;
}

Ans3:

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

void reverse(char*);

main()
{
char string[100];

printf("Enter a string\n");
gets(string);

reverse(string);

printf("Reverse of entered string is \"%s\".\n", string);

return 0;
}

void reverse(char *string)


{
int length, c;
char *begin, *end, temp;

length = strlen(string);

begin = string;
Prepared by: Rana Mehul
E-mail: [email protected]
end = string;

for ( c = 0 ; c < ( length - 1 ) ; c++ )


end++;

for ( c = 0 ; c < length/2 ; c++ )


{
temp = *end;
*end = *begin;
*begin = temp;

begin++;
end--;
}
}

11. Whether exit same as return?


Ans:
There's no difference of using "exit(0)" and "return 0" in the main function.
but if you use "exit(0)" in your subfunction, it will end your whole program, while
return will not.

Example with return:

#include <stdio.h>
void f(){
printf("Executing f\n");
return;
}

int main(){
f();
printf("Back from f\n");
}

If you execute this program it prints:

Executing f
Back from f

Another example for exit():


Prepared by: Rana Mehul
E-mail: [email protected]
#include <stdio.h>
#include <stdlib.h>

void f(){
printf("Executing f\n");
exit(0);
}

int main(){
f();
printf("Back from f\n");
}

If you execute this program it prints:

Executing f

Also notice that the parameter of exit() is an integer (it's the return status of the process
that the launcher process can get; the conventional usage is 0 for success or any other
value for an error).

The parameter of the return statement is whatever the return type of the function is. If the
function returns void, you can omit the return at the end of the function.

12. What is the difference between declaring a variable and defining a variable?
Ans: Declaration of a variable in C hints the compiler about the type and size of the
variable in compile time. No space is reserved in memory for any variable in case of
declaration.
e.g. : int a;
Here variable ‘a‘ is declared of data type ‗int‘

Defining a variable means declaring it and also allocating space to hold it.
We can say ― Definition = Declaration + Space reservation‖
e.g. : int a = 10; /* Here variable‘a‘ is described as an int to the compiler and
memory is allocated to hold value 10.*\

13. What is a pointer variable?


Ans: Pointer is a user defined data type which creates special types of variables
which can hold the address of primitive data type like char, int, float, double or user
defined data type like function, pointer etc. or derived data type like array, structure,
union, enum.
Prepared by: Rana Mehul
E-mail: [email protected]

Examples:
int *ptr;
int (*ptr)();
int (*ptr)[2];

In c programming every variable keeps two type of value.

1. Contain of variable or value of variable.


2. Address of variable where it has stored in the memory.

1) Meaning of following simple pointer declaration and definition:

int a=5;
int * ptr;
ptr=&a;

Explanation:

About variable a:

1. Name of variable : a
2. Value of variable which it keeps: 5
3. Address where it has stored in memory : 1025 (assume)

About variable ptr:

1. Name of variable : ptr


2. Value of variable which it keeps: 1025
3. Address where it has stored in memory : 5000 (assume)

Pictorial representation:

Note: A variable where it will be stored in memory is decided by operating system. We


cannot guess at which location a particular variable will be stored in memory.
Prepared by: Rana Mehul
E-mail: [email protected]
(2) Meaning of following pointer declaration and definition:

int a=50;
int *ptr1;
int **ptr2;
ptr1=&a;
ptr2=&pt1;

Explanation:

About variable a:
1. Name of variable : a
2. Value of variable which it keeps: 50
3. Address where it has stored in memory : 5000 (assume)

About variable ptr1:


4. Name of variable : ptr1
5. Value of variable which it keeps: 5000
6. Address where it has stored in memory : 9000 (assume)

About variable ptr2:


7. Name of variable : ptr2
8. Value of variable which it keeps: 9000
9. Address where it has stored in memory : 9555 (assume)

Pictorial representation of above pointer declaration and definition:

Note:

* is know as indirection operator which gives content of any variable.


& is know as reference operator which gives address where variable has stored in
memory.
Prepared by: Rana Mehul
E-mail: [email protected]

Cancellation rule of above two operators:

* and & operators always cancel to each other. i.e.

*&p=p

But it is not right to write:

&*p=p

Simple example:

What will be output of following c program?

#include<stdio.h>

int main(){

int x=25;
int *ptr=&x; //statement one
int **temp=&ptr; //statement two

printf(―%d %d %d‖.x.*ptr,**temp);

return 0;
}
Output: 25 25 25

Explanation:

As we know value of variable x is 25.

*ptr= *(&x) //from statement one


=*&x
=x //using cancellation rule
=25

**temp= **(&ptr)=*(*&ptr)=*ptr=*(&x)=*&x=x=25
Prepared by: Rana Mehul
E-mail: [email protected]

14. What is Operator overloading?


Ans: In object oriented computer programming, operator overloading—less
commonly known as operator ad-hoc polymorphism—is a specific case of
polymorphism, where different operators have different implementations depending
on their arguments.

Operator overloading is claimed to be useful because it allows the developer to


program using notation "closer to the target domain" and allows user-defined types a
similar level of syntactic support as types built into the language. It can easily be
emulated using function calls; for an example, consider the integers a, b, c:

a+b*c

In a language that supports operator overloading, and assuming the '*' operator has
higher precedence than '+', this is effectively a more concise way of writing:

add (a, multiply (b,c))

15. What is storage class?


Ans: Every C variable has a storage class and a scope. The storage class determines
the part of memory where storage is allocated for an object and how long the storage
allocation continues to exist. It also determines the scope which specifies the part of
the program over which a variable name is visible, i.e. the variable is accessible by
name. The are four storage classes in C are automatic, register, external, and static.

16. What do you know about stack and heap?


Ans: The text segment (sometimes also called the code segment) is where the
compiled code of the program itself resides. This is the machine language
representation of the program steps to be carried out, including all functions making
up the program, both user defined and system.

The remaining two areas of system memory is where storage may be allocated by the
compiler for data storage. The stack is where memory is allocated for automatic
variables within functions. A stack is a Last In First Out (LIFO) storage device where
new storage is allocated and deallocated at only one ``end'', called the Top of the
stack. This can be seen in Figure.
Prepared by: Rana Mehul
E-mail: [email protected]

When a program begins executing in the function main(), space is allocated on the stack
for all variables declared within main(), as seen in Figure (a). If main() calls a function,
func1(), additional storage is allocated for the variables in func1() at the top of the
stack as shown in Figure (b). Notice that the parameters passed by main() to func1() are
also stored on the stack. If func1() were to call any additional functions, storage would
be allocated at the new Top of stack as seen in the figure. When func1() returns, storage
for its local variables is deallocated, and the Top of the stack returns to to position shown
in Figure (c). If main() were to call another function, storage would be allocated for that
function at the Top shown in the figure. As can be seen, the memory allocated in the
stack area is used and reused during program execution. It should be clear that memory
allocated in this area will contain garbage values left over from previous usage.

The heap segment provides more stable storage of data for a program; memory allocated
in the heap remains in existence for the duration of a program. Therefore, global variables
(storage class external), and static variables are allocated on the heap. The memory
allocated in the heap area, if initialized to zero at program start, remains zero until the
program makes use of it. Thus, the heap area need not contain garbage.

17.Where memory does gets allocated for dynamic memory allocation?


Ans: The process of allocating memory at run time is known as dynamic memory
allocation.
According to the conceptual view the program instructions and global and static
variable in a permanent storage area and local area variables are stored in stacks. The
memory space that is located between these two regions in available for dynamic
allocation during the execution of the program. The free memory region is called the
heap. The size of heap keeps changing when program is executed due to creation and
death of variables that are local for functions and blocks. Therefore it is possible to
Prepared by: Rana Mehul
E-mail: [email protected]
encounter memory overflow during dynamic allocation process. In such situations, the
memory allocation functions mentioned below will return a null pointer.

Function Task

malloc Allocates memory requests size of bytes and returns a pointer to the Ist byte
of allocated space

calloc Allocates space for an array of elements initializes them to zero and returns
a pointer to the memory

free Frees previously allocated space

realloc Modifies the size of previously allocated space.

18.Program to find the index of the given array element.


Ans:
#include <stdio.h>

int find_index(int a[], int num_elements, int value);


void print_array(int a[], int num_elements);

void main(void)
{
int a[4] = {1, 2, 9, 17};
int index, value;

printf("\nArray:\n");
print_array(a, 10);

value = 1;
index = find_index(a, 4, value);
if (index == -1)
{
printf("The value %d was not found.\n", value);
}
else
{
printf("The value %d was found at %d\n", value, index);
}

value = 9;
index = find_index(a, 4, value);
if (index == -1)
{
printf("The value %d was not found.\n", value);
}
else
{
printf("The value %d was found at %d\n", value, index);
Prepared by: Rana Mehul
E-mail: [email protected]
}

value = 17;
index = find_index(a, 4, value);
if (index == -1)
{
printf("The value %d was not found.\n", value);
}
else
{
printf("The value %d was found at %d\n", value, index);
}
}

int find_index(int a[], int num_elements, int value)


{
int i;
for (i=0; i<num_elements; i++)
{
if (a[i] == value)
{
return(value); /* it was found */
}
}
return(-1); /* if it was not found */
}

void print_array(int a[], int num_elements)


{
int i;
for(i=0; i<num_elements; i++)
{
printf("%d ", a[i]);
}
printf("\n");
}

19. How will you avoid multiple header file inclusion?

Ans: If a header file happens to be included twice, the compiler will process its contents
twice. This is very likely to cause an error, e.g. when the compiler sees the same structure
definition twice. Even if it does not, it will certainly waste time.

The standard way to prevent this is to enclose the entire real contents of the file in a
conditional, like this:

/* File foo. */
#ifndef FILE_FOO_SEEN
#define FILE_FOO_SEEN

the entire file

#endif /* !FILE_FOO_SEEN */
Prepared by: Rana Mehul
E-mail: [email protected]
This construct is commonly known as a wrapper #ifndef. When the header is included
again, the conditional will be false, because FILE_FOO_SEEN is defined. The preprocessor
will skip over the entire contents of the file, and the compiler will not see it twice.

20..Dynamic memory allocations with examples


Ans: malloc() function
The malloc() function isn't limited to allocating memory for strings, of course; it can
allocate space for any storage need. This function allocates memory by the byte.
malloc()'s prototype is

void *malloc(size_t num);

The malloc() function allocates num bytes of storage space and returns a pointer to the
first byte.

int **create(int m, n)
{
int **p, i;

p = (int **)malloc(m*sizeof(int*));/* this will store base


order of all the row in p */

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

p[i] = (int *)malloc(n*sizeof(int));/* this will create


m row of n elements */
return p;
}

calloc() function

calloc() allocates a group of objects. The function prototype is

void *calloc(size_t num, size_t size);

Remember that size_t is a synonym for unsigned on most compilers. The argument
num is the number of objects to allocate, and size is the size (in bytes) of each
object. If allocation is successful, all the allocated memory is cleared (set to 0), and
the function returns a pointer to the first byte

#include <stdlib.h>
#include <stdio.h>
main()
Prepared by: Rana Mehul
E-mail: [email protected]

{
unsigned num;
int *ptr;

printf("Enter the number of type int to allocate: ");


scanf("%d", &num);

ptr = (int*)calloc(num, sizeof(int));

if (ptr != NULL)
puts("Memory allocation was successful.");
else
puts("Memory allocation failed.");
return(0);
}

realloc() function

The realloc() function changes the size of a block of memory that was previously
allocated with malloc() or calloc(). The function prototype is

void *realloc(void *ptr, size_t size);


The ptr argument is a pointer to the original block of memory. The new size, in
bytes, is specified by size.

/* Using realloc() to change memory allocation. */


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

main()
{
char buf[80], *message;

/* Input a string. */
Prepared by: Rana Mehul
E-mail: [email protected]

puts("Enter a line of text.");


gets(buf);
/* Allocate the initial block and copy the string to it. */

message = realloc(NULL, strlen(buf)+1);


strcpy(message, buf);

/* Display the message. */

puts(message);

/* Get another string from the user. */

puts("Enter another line of text.");


gets(buf);

/* Increase the allocation, then concatenate the string to it. */

message = realloc(message,(strlen(message) + strlen(buf)+1));


strcat(message, buf);

/* Display the new message. */


puts(message);
return(0);
}

free() function: When you allocate memory with either malloc() or calloc(), it is
taken from the dynamic memory pool that is available to your program. This pool is
sometimes called the heap, and it is finite. When your program finishes using a
particular block of dynamically allocated memory, you should deallocate, or free, the
memory to make it available for future use. To free memory that was allocated
dynamically, use free(). Its prototype is

void free(void *ptr);


Prepared by: Rana Mehul
E-mail: [email protected]

The free() function releases the memory pointed to by ptr. This memory must have
been allocated with malloc(), calloc(), or realloc().

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BLOCKSIZE 30000
main()
{
void *ptr1, *ptr2;
/* Allocate one block. */
ptr1 = malloc(BLOCKSIZE);

if (ptr1 != NULL)
printf("\nFirst allocation of %d bytes successful.",BLOCKSIZE);
else
{
printf("\nAttempt to allocate %d bytes failed.\n",BLOCKSIZE);
exit(1);
}

/* Try to allocate another block. */

ptr2 = malloc(BLOCKSIZE);

if (ptr2 != NULL)
{
/* If allocation successful, print message and exit. */

printf("\nSecond allocation of %d bytes successful.\n"


BLOCKSIZE);
exit(0);
}

/* If not successful, free the first block and try again.*/


Prepared by: Rana Mehul
E-mail: [email protected]

printf("\nSecond attempt to allocate %d bytes failed.",BLOCKSIZE);


free(ptr1);
printf("\nFreeing first block.");

ptr2 = malloc(BLOCKSIZE);

if (ptr2 != NULL)
printf("\nAfter free(), allocation of %d bytes
successful.\n", BLOCKSIZE);
return(0);
}

21.Bit wise operators with examples.


Ans:
Bitwise AND: The bitwise-AND (&) operator compares each bit of its first operand to
the corresponding bit of its second operand. If both bits are 1, the corresponding result bit
is set to 1. Otherwise, the corresponding result bit is set to 0.
Example:

Variable B3 B2 B1 B0
X 1 1 0 0
Y 1 0 1 0
Z = X &Y 1 0 0 0

Bitwisr OR ( | ) : The bitwise-inclusive-OR operator compares each bit of its first


operand to the corresponding bit of its second operand. If either bit is 1, the
corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.

Example:
Variable B3 B2 B1 B0
X 1 1 0 0
Y 1 0 1 0
Z=X|Y 1 1 1 0

Bitwisr XOR ( ^ ) : The bitwise-exclusive-OR operator compares each bit of its first
operand to the corresponding bit of its second operand. If one bit is 0 and the other bit is
Prepared by: Rana Mehul
E-mail: [email protected]
1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to
0.
Variable B3 B2 B1 B0
X 1 1 0 0
Y 1 0 1 0
Z=X^Y 0 1 1 0

Bitwise NOT (~) : There's only one unary bitwise operator, and that's bitwise NOT.
Bitwise NOT flips all of the bits.

Variable B3 B2 B1 B0
X 1 1 0 0
Y = (~X) 0 0 1 1

22. What is the use of Bitwise operators?

Ans: C, in particular, was created to make it easier to write operating systems. Rather
than write UNIX in assembly, which is slow process and not very portable (because
assembly is specific to an ISA), the goal was to have a language that provided good
control-flow, some abstractions (structures, function calls), and could be efficiently
compiled and run quickly.

Writing operating systems requires the manipulation of data at addresses, and this
requires manipulating individual bits or groups of bits.

That's where two sets of operators are useful: bitwise operators and bitshift operators.

Bitwise operators allow you to read and manipulate bits in variables of certain types.

23. Explain the program execution stages in C.


Ans:
The execution process of C can be divided in to multiple steps:
Preprocessing - Using a Preprocessor program to convert C source code in expanded
source code. "#includes" and "#defines" statements will be processed and
replaced actually source codes in this step.
Compilation - Using a Compiler program to convert C expanded source to assembly
source code.

Assembly - Using a Assembler program to convert assembly source code to object


code.
Prepared by: Rana Mehul
E-mail: [email protected]
Linking - Using a Linker program to convert object code to executable code. Multiple
units of object codes are linked to together in this step.

Loading - Using a Loader program to load the executable code into CPU for
execution.

Here is a simple table showing input and output of each step in the compilation
and execution process:

Input Program Output

source code > Preprocessor > expanded source code


expanded source code > Compiler > assembly source code
assembly code > Assembler > object code
object code > Linker > executable code
executable code > Loader > execution

24. Difference between typedef & #include preprocessor & side effects
Ans:
A typedef declaration lets you define your own identifiers that can be used in place of
type specifiers such as int, float, and double. A typedef declaration does not reserve
storage.

When an object is defined using a typedef identifier, the properties of the defined object
are exactly the same as if the object were defined by explicitly listing the data type
associated with the identifier.

The following statements declare LENGTH as a synonym for int and then use this typedef
to declare length, width, and height as integer variables:

typedef int LENGTH;


LENGTH length, width, height;

The following declarations are equivalent to the above declaration:

int length, width, height;


#include : Both user and system header files are included using the preprocessing
directive `#include'. It has two variants: #include <file> and #include “file”

If the file name is enclosed in angle brackets, for example:

#include <stdio.h>
Prepared by: Rana Mehul
E-mail: [email protected]
it is treated as a system-defined file, and the preprocessor searches for the file in a
manner defined by the preprocessor

If the file name is enclosed in double quotation marks, for example:

#include "payroll.h"

the preprocessor treats it as a user-defined file, and searches for the file in a manner
defined by the preprocessor.

Declarations that are used by several files can be placed in one file and included with
#include in each file that uses them.

25. Basic declarations of Structures, Unions, and Enumerations


Ans:
A structure/union is a collection of one or more variables, possibly of different data types,
grouped together under a single name for convenient handling.

Structure Declaration:

struct employee /* Defines a structure variable named temp */


{
char name[20];
int id;
long class;
} temp;

The employee structure has three members: name, id, and class. The name member is a 20-
element array, and id and class are simple members with int and long type, respectively. The
identifier employee is the structure identifier.

struct employee student, faculty, staff;

This example defines three structure variables: student, faculty, and staff. Each structure has the
same list of three members. The members are declared to have the structure type employee,
defined in the previous example.

Union Declaration:

union sign /* A definition and a declaration */


{
int svar;
unsigned uvar;
} number;
Prepared by: Rana Mehul
E-mail: [email protected]

This example defines a union variable with sign type and declares a variable named number
that has two members: svar, a signed integer, and uvar, an unsigned integer. This declaration
allows the current value of number to be stored as either a signed or an unsigned value.

Enumeration:

• Enumeration is a type specifier.


• It is a unique type with integer constants.
• Enumerations are unique types with values ranging over a set of named constants called
enumerators.
• The identifiers in an enumerator list are declared as constants of type int, and may appear
wherever constants are required

Enumeration Declaration:

enum DAY /* Defines an enumeration type */


{
saturday, /* Names day and declares a variable named */
sunday = 0, /* workday with that type */
monday,
tuesday,
wednesday, /* wednesday is associated with 3 */
thursday,
friday
} workday;

The value 0 is associated with saturday by default. The identifier sunday is explicitly set to 0.
The remaining identifiers are given the values 1 through 5 by default.

In this example, a value from the set DAY is assigned to the variable today.

26. What is call by value and call by reference


Ans:
Call by value: In this method, the value of each of the actual arguments in the calling function
is copied into corresponding formal arguments of the called function. In pass by value, the
changes made to formal arguments in the called function have no effect on the values of actual
arguments in the calling function..

Example:
void swap(int x, int y)
{
int temp;
temp = x;
x = y;
y = temp;
Prepared by: Rana Mehul
E-mail: [email protected]
printf(―swapped values are a=%d and b=%d‖,x,y);
}
Void main()
{
int a = 7, b=4;
printf("Original values are a = %d and b = %d", a, b);
swap(a,b);
}

Output:
Original values are a = 7 and b = 4
swapped values are a = 4 and b = 7.

This happens because when function swap() is invoked, the values of a and b gets copied
on to x and y. The function actually swaps x and y while the original variables a and b
remains intact.

Call by Reference: In this method, the addresses of actual arguments in the calling function are
copied into formal arguments of the called function. This means that using these addresses, we
would have an access to the actual arguments and hence we would be able to manipulate them.
C does not support Call by reference. But it can be simulated using pointers.
Example:
void swap(int *x, int *y)
{
int t;
t = *x; /* assign the value at address x to t */
*x = *y; /* put the value at y into x */
*y = t; /* put the value at to y */
}
int main() {
int m = 10, n = 20;
printf("Before executing swap m=%d n=%d\n", m, n);
swap(&m, &n);
printf("After executing swap m=%d n=%d\n", m, n);
return 0;
}

Output:
Before executing swap m=10 n=20
After executing swap m=20 n=10

Explanation:
In the main function, address of variables m, n are sent as arguments to the function 'swap'. As
swap function has the access to address of the arguments, manipulation of passed arguments
inside swap function would be directly reflected in the values of m, n.

27. What is difference between array of characters and string


Ans: When we declare array of char it has to be terminated by null but termination by
null in case of string is automatic,i.e.the compiler automatically puts a null char
when we insert a string for example "xyz" for the string "xyz\0", but for a char array we
need to assign a place for it for example a[4] contains three char & a null character.
Prepared by: Rana Mehul
E-mail: [email protected]
28. Predict the output
void main()
{
int const * p=5;
printf("%d",++(*p));
}

Ans: Compilation Error

29. What is the difference between pointer to constant and constant pointer. write
down the same..
Ans:
Pointer to constant:
This is a pointer which points to a constant variable assigned to that pointer. Another
pointer can also be assigned to the same constant variable to point to.
Example :
char Const a;
char *p,*q;
p=&a;
q=&a;

Constant Pointer:
It is a pointer which points to the same memory location or to same address and whatever
value the variable which is pointed by the pointer holds.

Example :
char a;
char const *p;
p=&a;

Here variable ‗a‘ is a memory location having an address and that variable contains
some character data. This pointer ―p‖ points to the same address ( a ) however the value
in variable ‗a‘ changes.

30. Any sorting/searching method


Ans:
Types of sorting:
bubble sort,
selection sort,
insertion sort,
heapsort,
merge sort and
quicksort.

Searching techniques:
Prepared by: Rana Mehul
E-mail: [email protected]
Binary Search
Hash tables method

31. What are macros? What are the advantages and disadvantages?
Ans:
Macros are preprocessor statements which will have specific set of instructions which are
repeated in source code for several times and which wil be replaced at every call made.

Advantages:

It saves a lot of time that is spent by the compiler for invoking / calling the
functions and hence increases the speed of the execution.
Any modification to instructions in macro reflects in every call.
Reduce source code length.
Disadvantage:
The disadvantage of the macro is the size of the program. The reason is,
the pre-processor will replace all the macros in the program by its real definition
prior to the compilation process of the program.
Prepared by: Rana Mehul
E-mail: [email protected]
Testing skills (unit, S/w Integration, HSI etc)

1. Differentiate between verification and validation


Ans:
Validation is the process of ensuring that the specified requirements are sufficiently
correct, complete, unambiguous, consistent, self-content (no reference to a document: to
extract the requirement from the document) realizable and verifiable so that the product
will meet the applicable airworthiness requirements.

―Are we building the right product?‖

Verification is the evaluation of an implementation of requirements (act of creating a


physical reality from a specification) to determine that they have been met.

―Are we building the product right?‖

2. What is Black box and white box testing


Ans:
Black-box testing is a method of software testing that tests the functionality of an
application as opposed to its internal structures or workings. Specific knowledge of the
application's code/internal structure and programming knowledge in general is not
required. Test cases are built around specifications and requirements, i.e., what the
application is supposed to do. It uses external descriptions of the software, including
specifications, requirements, and designs to derive test cases. These tests can be
functional or non-functional, though usually functional. The test designer selects valid
and invalid inputs and determines the correct output. There is no knowledge of the test
object's internal structure.

This method of test can be applied to all levels of software testing: unit, qintegration,
functional, system and acceptance. It typically comprises most if not all testing at higher
levels, but can also dominate unit testing as well.

White-box testing (also known as clear box testing, glass box testing, transparent box
testing, and structural testing) is a method of testing software that tests internal structures
or workings of an application, as opposed to its functionality (i.e. black-box testing). In
white-box testing an internal perspective of the system, as well as programming skills,
are required and used to design test cases. The tester chooses inputs to exercise paths
through the code and determine the appropriate outputs. This is analogous to testing
nodes in a circuit, e.g. in-circuit testing (ICT).

While white-box testing can be applied at the unit, integration and system levels of the
software testing process, it is usually done at the unit level. It can test paths within a unit,
paths between units during integration, and between subsystems during a system level
Prepared by: Rana Mehul
E-mail: [email protected]
test. Though this method of test design can uncover many errors or problems, it might not
detect unimplemented parts of the specification or missing requirements.

White-box test design techniques include:

o Control flow testing


o Data flow testing
o Branch testing
o Path testing

3. Different levels of testing


Ans: The different levels of testing are:
* Unit testing
* Integration testing
* System testing
* Acceptance testing
* Regression testing

4. Objectives of unit testing, S/w Integration testing, HSI testing

Ans: Hardware/Software Integration Testing : To verify correct operation of the


software in the target computer environment.
** HSI focuses also on:
• Execution time (too much or too little) and incorrect interrupt handling
• Software responses to hardware transients and failures
• Data bus and other resource contention problems
• BIT/BITE failures
• Hardware/software interface errors
• Incorrect behavior of feedback loops (hardware and software)
• Incorrect control of of hardware devices under software control
• Stack overflows
• Field-Loadable software equipment and integrity problems
• Violations of software partitioning

Software Integration Testing: To verify the interrelationships between software


requirements and components and to verify the implementation of the software
requirements and the software components within the software architecture.
** Software integration testing Focus on and consider the following:
• The inter-relationships between the software requirements
• The implementation of requirements by the software architecture
• Software component interaction. Incorrect initialization of variables and constants
• Parameter passing errors
• Data corruption, especially global data
Prepared by: Rana Mehul
E-mail: [email protected]
• Inadequate end-to-end numerical resolution
• Incorrect sequencing of events and operations
• Structure boundary problems, memory overlays, incorrect hardware addresses, missing
software components

Low-level testing : To verify the implementation of the software low level requirements.
** Low level testing Focus on and consider the following:
• Demonstrate that each software component complies with its low-level requirements
• Algorithms failing to satisfy software requirements
• Incorrect loop operations and logic decisions
• Various input data conditions including:
–Failure to process legitimate combinations of input conditions
–Incorrect responses to missing or corrupted input data
• Incorrect fault handling (overflows, underflows), pointer problems, and so on
• Incorrect sequences of operation
• Algorithm precision, accuracy or performance

5. Techniques used for testing such as normal range, BVA, equivalence


partitioning, robust testing etc.
Ans:
Normal range testing:
Normal range testing includes but is not limited to
equivalence class testing using valid classes
boundary value analysis testing using valid boundaries
state transitions using valid transition criteria
verify valid Boolean operations and variable usage
verify operation with nominal timing constraints
verify nominal operation - time constants, iterative algorithms and so on

Robustness testing:
Robustness testing or abnormal range testing includes but is not limited to
• equivalence class testing using invalid classes
• boundary value analysis testing using invalid boundaries
• system restart (or start up) under abnormal conditions
• corrupt input data
• loop termination (looping on out of range values)
• excessive timeloading
• time constants that are shortened and/or extended
• attempt to provoke invalid state transitions

Equivalence partitioning:
(
Equivalence partitioning also called Equivalence Class Partitioning or ECP is a )
software testing technique that divides the input data of a software unit into partitions of
data from which test cases can be derived. In principle, test cases are designed to cover
Prepared by: Rana Mehul
E-mail: [email protected]
each partition at least once. This technique tries to define test cases that uncover classes
of errors, thereby reducing the total number of test cases that must be developed.
In rare cases equivalence partitioning is also applied to outputs of a software
component, typically it is applied to the inputs of a tested component. The equivalence
partitions are usually derived from the requirements specification for input attributes that
influence the processing of the test object. An input has certain ranges which are valid
and other ranges which are invalid. Invalid data here does not mean that the data is
incorrect, it means that this data lies outside of specific partition

Boundary Value Analysis:


Boundary value testing differs from equivalence partitioning in two respects
1. Rather than selecting any element in an equivalence class as being
representative, boundary value testing requires that one or more elements be selected
such that each edge of the equivalence partition is the subject of a test.
2. Rather than just focusing attention on the input conditions (input space), test
cases are also derived by considering the result space (i.e., output equivalence classes).

Error Guessing:
In error guessing, a test designer summarizes, both by intuition and experience, certain
probable types of errors and then writes test cases to expose these errors.
Typical errors include divide by zero, null pointers, or invalid parameters.
Error guessing has no explicit rules for testing;test cases can be designed
depending on the situation, either drawing from functional documents or when an
unexpected/undocumented error is found while testing operations.

6. What is data coupling/control coupling


Ans:
Data coupling
The dependence of a software component on data not exclusively under the control of
that software component.

Control coupling
The manner or degree by which one software component influences the execution of
another software component.

With the current testing approach widely being followed across the aerospace
industry, Hardware-Software integration tests are performed at prototype level and once
the requirements are stable, requirement based tests (RBT) are formally performed to
show compliance as per DO178B - review of requirements, design and code along with
RBT (involves various level of tests -bloack box, white box, unit/module/isolation tests
as appropriate). Performing Software-Software Integration tests upon these verification
evidence already generated adds on to time and cost of the project.

Data Coupling & Control Coupling objective can be achieved with following
activities:
a) Architecture&Design Reviews to check the data flow between components.
Prepared by: Rana Mehul
E-mail: [email protected]
b) Source Code reviews/analysis to check Calling sequences,Data read-write access,
worst case execution time.
c) Memory map file anyalsis to check the robust memory management.
d) SIT (for uncovered HLR's during HSIT) to check the data flow and control flow b/w
compoents implementing uncovered requirements from HSIT.
e) Module testing to check the parameter passing (using stub check parameter on entry
concepts in LDRA ,RTRT,,,etc), external function calling sequence(using Stub order
concept in LDRA,RTRT ...etc) and global data intialisation.

7. Given a software code how we can perform Data Coupling and Control coupling
manually?
Ans:
In the C language control coupling manifests in one of three ways:

(1) Static function calls.


• In the case of static function calls (case 1); statement coverage is sufficient to determine
if all possible calling points for a function have been executed by the test procedures.

(2) Sub-functions (See Note 1)


• In the case of sub-functions (case 2); analysis should reveal if the controlling parameter
a constant determined at compile-time or whether the controlling parameter may be
dynamically modified during execution.
• If the controlling parameter is a constant determined at compile-time, this case is
equivalent to case 1.
• If the controlling parameter may be dynamically modified during execution, this case is
equivalent to case 3.

(3) Dynamic function calls (i.e. function called through a pointer.)


• Points where a function is called through a pointer (case 3); it is necessary to determine
whether (a) the function pointer has been initialized before use, (b) what the range of
possible values for the function pointer are, and (c) that all possible values of the function
pointer within that range have been executed.
• In the case of function pointers which belong to a jump table which is initialized at
compile-time, this case is reduces to case 1.
• In the case of function pointers that are initialized at powerup, the calling point must be
exercised in all potential configurations of the jump table.

Data coupling manifests as:

(1) Parameters passed to a function.


• In the case of parameters passed to the function (case 1); statement coverage is
sufficient to determine whether all control paths through the function that might be
influenced by the parameter set have been exercised.

(2) Global data set or used by the function whose value is determined at compile-time or
Prepared by: Rana Mehul
E-mail: [email protected]
as part of system configuration.
• In the case of global configuration data (case 2); analysis should determine the
equivalency classes of all potential configurations. Structural coverage analysis should be
executed under all equivalency classes.

(3) Global data set or used by the function which represents the current state of execution
of the system.
• In the case of global state data (case 3); analysis should determine the potential states
(or their equivalency classes). Structural coverage analysis through instrumentation
should determine if all states have been entered and all legal transitions between states
have been exercised.

Note 1: Sub-functions exist where a function parameter determines which of multiple


independent execution paths is taken through a function. Usually the parameter is used to
determine which case of a large switch statement is executed.

An Approach

Perform a review of the flight software to confirm data coupling and control coupling
among the software components.

To satisfy the control coupling objective, use the structural coverage results to provide
evidence that all functions were executed through high-level test cases. For functions that
could not be exercised by high-level tests, develop additional functional analyses and add
to the Software Verification Cases and Procedures (SVCP). The intent is to provide
confidence that the requirements-based testing has completely exercised the code
structure.

To satisfy the data coupling objective, this analysis includes functional parameters, global
variables, external data, stored data, and resource contention. Analyze the SVCP and
associate test code to confirm the verification coverage of the data coupling in the code.
As with the control coupling, structural coverage results can used to provide evidence
that the data coupling through parameters was covered.

8. Explain Test Life cycle


Ans:

STLC determines what test activities should be carried out and when should they be
completed.
Prepared by: Rana Mehul
E-mail: [email protected]

Requirement Stage
This is the initial stage of the software testing life cycle process. In this phase the
developers take part in analyzing the requirements for designing a product. The role of
software testers is also necessary in this phase as they can think from the 'users' point of
view which the developers may not. Thus a team of developers, testers and users can be
formed, to analyze the requirements of the product. Formal meetings of the team can be
held in order to document the requirements which can further be used as software
requirements specification or SRS.

Test Planning
Test planning means to predetermine a plan well in advance to reduce further risks. A
well-designed test plan document plays an important role in achieving a process-oriented
approach. Once the requirements of the project are confirmed, a test plan is documented.
The test plan structure is as follows:

1. Introduction: This describes the objective of the test plan.


Prepared by: Rana Mehul
E-mail: [email protected]
2. Test Items: The items that are required to prepare this document will be listed
here such as SRS, project plan.
3. Features to be tested: This describes the coverage area of the test plan, that is, the
list of features to be tested; that are based on the implicit and explicit
requirements from the customer.
4. Features not to be tested: The incorporated or comprised features that can be
skipped from the testing phase are listed here. Features that are out of scope of
testing, like incomplete modules or those on low severity, for example, GUI
features that don't hamper the process can be included in the list.
5. Approach: This is the test strategy that should be appropriate to the level of the
plan. It should be in acceptance with the higher and lower levels of the plan.
6. Item pass/fail criteria: Related to the show stopper issue. The criteria used has to
explain which test item has passed or failed.
7. Suspension criteria and resumption requirements: The suspension criteria
specifies the criteria that is to be used to suspend all or a portion of the testing
activities, whereas resumption criteria specifies when testing can resume with the
suspended portion.
8. Test deliverable: This includes a list of documents, reports, charts that are
required to be presented to the stakeholders on a regular basis during the testing
process and after its completion.
9. Testing tasks: This phase lists the testing tasks that need to be performed. This
includes conducting the tests, evaluating the results and documenting them based
on the test plan designed. This also helps users and testers to avoid incomplete
functions and prevent waste of resources.
10. Environmental needs: The special requirements of the test plan depending on the
environment in which the application has to be designed are listed here.
11. Responsibilities: This phase assigns responsibilities to people who can be held
responsible in case of a risk.
12. Staffing and training needs: Training on the application/system and on the testing
tools to be used needs to be explained to the staff members who are responsible
for the application.
13. Risks and contingencies: This emphasizes on the probable risks and various
events that can occur and what can be done in such situations.
14. Approval: This decides who can approve the process as complete and allow the
project to proceed to the next level that depends on the level of the plan.

Test Analysis
Once the test plan documentation is done, the next stage is to analyze what types of
software testing should be carried out at the various stages of SDLC.

Test Design
Test design is done based on the requirements of the project documented in the SRS. This
phase decides whether manual or automated testing is to be done. In automation testing,
different paths for testing are to be identified first and writing of scripts has to be done if
required. An end-to-end checklist that covers all the features of the project is necessary in
the test design process.
Prepared by: Rana Mehul
E-mail: [email protected]
Test Verification and Construction
In this phase, the test plan, test design and automated test script are completed. Stress and
performance testing plans are also completed at this stage. When the development team is
done with a unit of code, the testing team is required to help them in testing that unit and
report any bug in the product, if found. Integration testing and bug reporting is done in
this phase of software testing life cycle.

Test Execution
Planning and execution of various test cases is done in this phase. Once the unit testing is
completed, the functionality of the tests is done in this phase. At first, top-level testing is
done to find out the top-level failures and bugs are reported immediately to the
development team to get the required workaround. Test reports have to be documented
properly and the bugs have to be reported to the development team.

Result Analysis
After the successful execution of the test case, the testing team has to retest it to compare
the expected values with the actual values, and declare the result as pass/fail.

Bug Tracking
This is one of the important stages as the Defect Profile Document (DPD) has to be
updated for letting the developers know about the defect. Defect Profile Document
contains the following

1. Defect Id: Unique identification of the Defect.


2. Test Case Id: Test case identification for that defect.
3. Description: Detailed description of the bug.
4. Summary: This field contains some keyword information about the bug, which
can help in minimizing the number of records to be searched.
5. Defect Submitted By: Name of the tester who detected/reported the bug.
6. Date of Submission: Date at which the bug was detected and reported.
7. Build No.: Number of test runs required.
8. Version No.: The version information of the software application in which the
bug was detected and fixed.
9. Assigned To: Name of the developer who is supposed to fix the bug.
10. Severity: Degree of severity of the defect.
11. Priority: Priority of fixing the bug.
12. Status: This field displays current status of the bug.

Reporting and Rework


Testing is an iterative process. The bug that is reported and fixed by the development
team, has to undergo the testing process again to assure that the bug found has been
resolved. Regression testing has to be done. Once the Quality Analyst assures that the
product is ready, the software is released for production. Before release, the software has
to undergo one more round of top-level testing. Thus testing is an ongoing process.

Final Testing and Implementation


This phase focuses on the remaining levels of testing, such as acceptance, load, stress,
Prepared by: Rana Mehul
E-mail: [email protected]
performance and recovery testing. The application needs to be verified under specified
conditions with respect to the SRS. Various documents are updated and different matrices
for testing are completed at this stage of the software testing life cycle.

Post Implementation
Once the test results are evaluated, the recording of errors that occurred during the
various levels of the software testing life cycle, is done. Creating plans for improvement
and enhancement is an ongoing process. This helps to prevent similar problems from
occurring in the future projects. In short, planning for improvement of the testing process
for future applications is done in this phase.

9. Explain Defect Life cycle.


Ans:

In the figure shown below all the defect reports move through a series of clearly
identified states.

1. A defect is in open state when the tester finds any variation in the test results during
testing, peer tester reviews the defect report and a defect is opened.

2. Now the project team decides whether to fix the defect in that release or to postpone it
for future release. If the defect is to be fixed, a developer is assigned the defect and
defect moves to assigned state.
Prepared by: Rana Mehul
E-mail: [email protected]
3. If the defect is to be fixed in later releases it is moved to deferred state.

4. Once the defect is assigned to the developer it is fixed by developer and moved to
fixed state, after this an e-mail is generated by the defect tracking tool to the tester
who reported the defect to verify the fix.

5. The tester verifies the fix and closes the defect, after this defect moves to closed state.

6. If the defect fix does not solve the issue reported by tester, tester re-opens the defect
and defect moves to re-opened state. It is then approved for re-repair and again
assigned to developer.

7. If the project team defers the defect it is moved to deferred state, after this project
team decides when to fix the defect. It is re-opened in other development cycles and
moved to re-opened state. It is then assigned to developer to fix it.

10. What is a dead code and deactivated code. How will you identify the dead code?
Ans:
Dead code is an executable Object Code (or data) which exists as a result of a software
development error but cannot be executed (code) or used (data) in any operational
configuration of the target computer environment. It is not traceable to a system or
software requirement.

Example
int f (int x, int y)
{
int z=x+y;
return x*y;
}

In the above example the sum of x and y is computed but never used. It is thus dead code
and can be removed.

public void Method(){


final boolean debug=false;

if (debug){
//do something...
}
}

In the above example "do something" is never executed, and so it is dead code.

Dead code can be found during low-level testing.

Deactivated code - Executable object code (or data) which by design is either (a) not
intended to be executed (code) or used (data), for example, a part of a previously
Prepared by: Rana Mehul
E-mail: [email protected]
developed software component, or (b) is only executed (code) or used (data) in certain
configurations of the target computer environment, for example, code that is enabled by a
hardware pin selection or software programmed options.

Example : Conditional compilation

//For EPIC-TOLD

#ifdef _EPIC_TOLD

enum fmsActivationData
{
PERF_DATA_PAGE = 0,
CLIMB_PAGE = 1,
DESCENT_PAGE = 2,
FLIGHT_PLAN_PAGE = 3,
DEPART_RWY_PAGE = 4,
ARRIVAL_RWY_PAGE = 5
};

enum toldActivationData
{
TOINIT_1_PAGE = 0,
LDINIT_1_PAGE = 1
};

#endif

11. What is stub?


Ans: Stubs are the replacements for missing components that the components being
tested will call as a part of the test.
For example, if we have Modules X,Y & Z . X module is ready and Need to be
tested , But it calls functions from y and z.(Which is not yet ready). So to test module X,
we will write a Small Dummy piece of code which Simulates Y and Z Whch will return
values for X, These pice of Dummy code is Called Stub.

12. What is RBT?


Ans: Requirement Based Testing is a type of testing which is performed against software
requirements. RBT is the most effective at revealing errors. Guidance for requirements-
based test case selection includes:
a. To implement the software testing objectives, two categories of test cases should
be included: normal range test cases and robustness(abnormal) test cases.
b. The specific test cases should be developed from the software requirements and
the error sources inherent in the software development processes.
Prepared by: Rana Mehul
E-mail: [email protected]
13. What is meant by instrumenting a code?
Ans: Instrumenting a code means inserting probes at strategic points (such as break
points, control flow jumps, program labels, the start and finish of procedures etc.) to
monitor or measure the level of a product‘s performance, to diagnose errors and writing
trace information.
Instrumented code probes are simple function calls which perform three tasks:
Create and open execution history file.
Write information about the program execution to this file through an
output stream.
Close the file

14. What is operating range and machine range?

15. What will you do when your test case fails?


Ans: When the test case fails:
1. Need to check whether all the input conditions are correctly given as per the SRS.
2. Then if the test procedure is correct.
3. If both the above things are correct then note it into a file that there is a defect in
implementation of this requirement and discuss with team lead.
4. If team lead agrees that there is defect then raise a defect log.

16. Why review is required in verification?


Ans: Reviews provide a qualitative assessment of correctness. A review may consist of
an output of a process guided by a checklist or a similar aid.
There are six kinds of reviews:
Requirement reviews
Design reviews
Code reviews
Test procedures reviews
Test results reviews
Traceability reviews

17. What do you mean by derived requirement?


Ans: A derived requirement is something that we infer or derive from a user requirement.
A derived requirement (regardless of whether it is high level or low level) does not
traceable directly to a higher level requirement.

Example:

Consider a HLR requirement a= b / c where c holds a value from 0 to 100.


But in HLR there is no description about division by 0 condition.

To avoid division by ZERO a derived requirement has to added as follows


c= MIN(101,MAX(c,0.00001));
Prepared by: Rana Mehul
E-mail: [email protected]
Also there is no traceability of this derived requirement with HLR.

An illustative list (but not a complete list) will make the point of what is usually
considered derived requirements:
1. hardware dependent features such as frequency, big endien- little endien
considerations, code to trap hardware failures, code to implement SEU avoidance etc if
they are not already specified in the high level requirements- I have personally seen a
case where hardware controller was switched and the nuclear reactor software almost
caused a meltdown!
2. defensive programming in order to avoid computational errors, processor errors, avoid
what has already been published as processor errata as applicable, known linker and
compiler deficiencies etc
3. design specific decisions such as backup, redundancy and partitioning. it is important
to examine how these features work with respect to system safety. For example what
state will be backup system be when the system is up after a primary system failure.
4. domain specific knowledge of previously observed failures - this is a tricky one since a
lot of companies keep track of the type of possible errors when their system interacts with
the other avionics and this is often their domain knowledge. A new company will have to
build up this knowledge by experience and by hiring experienced personnel.
5. aircraft specific "personality" features - how does a particular aircraft contribute to the
physics of the problem. This is usually implemented as configuration parameters - then
this is not considered to be derived requirements. but in some cases there is elaborate
code.

Some other examples:

Suppose you are building a flight display. A top level requirement may be to display
altitude both as a graphic and numerically. Now, if you decide to implement the graphical
software via OpenGL, a derived requirement may be to have a glBegin() function. It
doesn't trace directly to the altitude requirement, but can when coupled with the decision
to use OpenGL.

At a low level, the same principle applies. Suppose you have a requirements on when
landing wheels can and cannot be retracted. Now you decide to implement this code as a
state machine. A low level derived requirement could then be the need to have a state
variable to control the state machine.

18. Explain V model for SDLC.


Ans:
The V Model is an enhanced version of the classic waterfall model whereby each level of
the development lifecycle is verified before moving on to the next level. With this model,
testing explicitly starts at the very beginning, i.e. as soon as the requirements are written.
Here, by testing we mean verification by means of reviews and inspections, i.e. static
testing. This helps in identifying errors very early in the lifecycle and minimizes potential
future defects appearing in the code later in the lifecycle.
Prepared by: Rana Mehul
E-mail: [email protected]

Each level of the development lifecycle has a corresponding test plan. i.e. as each phase
is being worked on, a test plan is developed to prepare for the testing of the products of
that phase. Be developing the test plans, we can also define the expected results for
testing of the products for that level as well as defining the entry and exit criteria for each
level.

In the V-Model the test activities are spelled out to the same level of detail as the design
activities. Software is designed on the left-hand (downhill) part of the model, and built
and tested on the right-hand (uphill) part of the model. Note that different organizations
may have different names for the development and testing phases.

The correspondences between the left and right hand activities are shown by the lines
across the middle of the V, showing the test levels from component testing at the bottom,
integration and system testing, and acceptance testing at the top level.

Advantages

Each phase has specific deliverables.


Higher chance of success over the waterfall model due to the development of test
plans early on during the life cycle.
Time concern in comparison with the waterfall model is low or even we can say
50% less.
Works well for small projects where requirements are easily understood.
Prepared by: Rana Mehul
E-mail: [email protected]
Utility of the resources is high.

Disadvantages

Very rigid, like the waterfall model.


Little flexibility and adjusting scope is difficult and expensive.
Software is developed during the implementation phase, so no early prototypes of
the software are produced.
Model doesn‘t provide a clear path for problems found during testing phases.

19. Software verification planning process in Honeywell.


Ans: The diagram below shows the SW Verification planning process followed in
Honeywell.

Develop High-Level SVP

Develop Low-Level SVP

Develop Traceability Feed Test Case CM ID


Matrix tables within SVP Numbers back into SVP
and link these tables to
DOORS requirements
database

Develop Serena
ChangeMan Test Case
Infrastructure within
PVCS Dimensions

Feed Test Case


Development Manpower
Hours and Personnel
Numbers into Master
Schedule

Create the Design For


Test (DFT) Requirements
document from the SVP
document

Create the individual SI


Test Case Header
Template files from the
SVP document
Prepared by: Rana Mehul
E-mail: [email protected]
20. What are the inputs for HSI, SI and LLI?
Ans:
For HSI: SVP, SRS, DIRS, IICD.
For SI: SRS, SVP & SDD (SI is being carried out against the computer software
Component(CSC). Computer Software Component is all those functions/procedures,
which call at least one or more CSU.)
For UT: SVP & SDD. (UT is being carried out against the CSU(computer software unit).
CSU is the is the lowest level function/procedure in the SW architecture, which does
not call any other function/procedure.)

 SRS gives information about requirements to be tested.


 SVP tells the test strategy
 SDD is used for identifying design component and the dependent components.

21. How do you test dead code or deactivated code as per DO-178B.
Ans: We do not test. Testing as per DO-178B is requirement driven. We just tests the
requirements. If the structural coverage shows less than 100% coverage, one of the
following 3 could apply:
(a). The test is inadequate/incorrect.
(b). There is a dead code.
(c). There is a deactivated code.
In the case of (a), one just digs deeper and ensures that the requirement is completely and
correctly tested. In the other two cases, I would just raise a PR and my job is done.
Unless there is a requirement that tells me how to handle deactivated code, I wouldn‘t
bother.
Prepared by: Rana Mehul
E-mail: [email protected]

Process Skills (DO178B, DOD2167A etc)

1. What is D0-178B, whether it is a standard or guideline?


Ans:
‗DO‘ stands for Document and ‗178‘ is the number allocated by RTCA and ‗B‘
indicates the version.
DO-178B is a guideline for the production of software for airborne systems and
equipments. These guidelines are in the form of:
Objectives for software life cycle processes
Descriptions of activities and design considerations for achieving those
objectives.
Descriptions of the evidence that indicate that the objectives have been satisfied.

2. Which systems need to be certified under DO-178B?


3. What determines the certification basis for the software?
4. How many levels of software’s are there as per DO178B?
5. What are the failure conditions associated with each level?
6. What do you mean by a requirement?
7. What is meant by “coverage”?
8. What kind of coverage needs to be obtained at each level?
9. How many objectives needs to be satisfied at each level?
10. What do you mean by “independent objectives”?
11. What is Design Assurance Level?
12. What 5 major plans are typically created to document the planning information
required by DO-178B?
Ans: As per DO-178B Sec.4 the following plans are being created during planning
precess:
Plan for software aspects of certification (PSAC)
Software Development Plan (SDP)
Software Verification Plan (SVP)
Software quality Assurance Plan(SQAP)
Software Configuration Management Plan(SCMP)

13. What plan contains a description of testing method?


Ans: Software Verification Plan(SVP)

14. Where does Do-178B specify the lify cycle that a project must follow?
Ans: DO-178B does not specify any life cycle. Honeywell traditionally chooses to use an
iterative ―Waterfall‖ life cycle.

15. What are the software development processes?


Ans: The software development processes are:
Software requirement Process
Software Design Process
Prepared by: Rana Mehul
E-mail: [email protected]
Software Coding Process
Integration process

16. Which members of the project team should become familiar with the
development process defined in SDP?
Ans: The software development process must be understood by the development team
and the test team. Refer DO-178B sec.4. For example, it is important that the project
team understands how all work is controlled if ―change documents‖(i.e. SCRs, PCRs etc.)
are embedded in a configuration management tool such as PVCS.

17. What main event occurs during the integration phase of development?
Ans: The executable object code is integrated into the target hardware(DO-178B sec 5.4)

18. Which development process must occur prior to coding?


Ans: DO-178B does not guide/tell about the sequences of the development work.
Prototyping is allowed. Also, the transition criteria must be defined in the plans snd then
followed. If the plans state that a ―Waterfall‖ process will be used, then a waterfall
process must be used.
Approved pplans must be followed.

19. Can the code be formally reviewd for credit before the design review has been
conducted?
Ans: No. The design review must be completed before the code can be reviewd if formal
credit is sought.
(We can always review the code informally at any time for no credit. This is
useful for ―wringing out‖ the system).
The verification process must oocur ―in order‖. DO-178B uses the term
―transition criteria‖ to refer them.

20. How does someone finds the design, code and the test procedure(s) associated
with a specific requirement?
Ans: All software requirements must be traced to the design, code and test procedure.
Typically, honeywell chooses to identify all requirements by the kye word ―shall‖. All
―shall‖ may then be traced to the design, code and the test procedures.

21. What are the four integral processes?


Ans:
Verification
Configuration Mangement
Quality Assurance
Certification Liasion.

22. What are three categories of verification?


Ans: Verification is defined as:
Reviews (sometimes called as ―inspections‖)
Analysis
Prepared by: Rana Mehul
E-mail: [email protected]
Test.

23. What analysis is typically assisted by the use of a qualified tool?


Ans: Structural coverage analysis is performed using a qualified verification tool to
measure coverage during requirements-based testing.

24. What are the two main analysis required to determine when the testing effort is
complete?
25. Explain requirement coverage analysis.
26. Why do we need to perform structural coverage analysis?
27. How to perform structural coverage analysis on assembly source code for level A
software?
28. Do-178B gives the guidelines for three traceability. Which 3?
29. What is the difference between integration process and integration testing?
30. What is the role of DERs?
31. What do you know about TSO?
32. What is the role of the QA engineer?
33. What is the significance of MCDC?
34. How many MCDC test cases are required for a combination of n variables?
35. Write test cases for c=a+b; (simple adder block) and identify which are
boundary, normal and robustness (assuming a and b can range from [0..5])
36. Write test cases for “A or (B and C)” and “A and (B or C)”
37. What is “Unique-cause” approach for MCDC?
38. What do you know about Masking approach for MCDC?
39. How many number of test cases are required for condition (A>10) ? A is an
integer.
40. Contents of a peer review checklists.
41. How many documents, as a minimum, are required to be submitted to the
certifying authority? Name them.
Ans: Three documents.
1. PSAC (Plan for Software Aspects of Certification).
2. SAS (Software Accomplishment Summary).
3. SCI (Software Configuration Index)

42. Different SOI’s.


Ans: SOI stands for Stage Of Involvement (For DER/Certification authority).
The four stage of involvements are:
1. Software Planning
2. Software Development
3. Software verification
4. Final certification.

43. What are control categories?


Ans: Control Categories (CC1 & CC2) define the software configuration management
processes and activities for controlling software life cycle data. CC2 objectives are a
subset of CC1 objectives. The separation into CC1 and CC2 eases the burden of
Prepared by: Rana Mehul
E-mail: [email protected]
Configuration Management workload. If every data of software life cycle process were
controlled in a same category then it would be extremely time consuming to maintain all
of the required documentation. The other reason for two different categories is, at
different safety levels some items(documants) are less critical than others and don‘t need
to be as tightly controlled.

Avionics

1. Different forces acting on aircraft while flying and how aircraft is getting that.
2. Different motions of aircraft and what helps aircraft for moving in different
directions.
3. Different phases of a flight
4. Explain the project worked on. What is level of that software as per DO178B. What
all the impacts of that software failure.
5. Real Time example of avionics software‘s for different levels of DO178B.
6. AFDX message format
7. Any A429 Label format BCD, BNR etc

You might also like