## Embedded C Test Upwork

How many bits are used by the watchdog timer in the SFRs for interrupt control?

a. One
b. Two
c. Three
d. None of the above.

Fill in the blank:
A connected graph is said to be an Eulerian graph, only if all the vertices of the graph have _______ degree.

a. an odd
b. an even
c. either an even or an odd

What will be the output of the following program?
#include <stdio.h>
void abc(int num1[], int size)
{
int a = 0, b = size–1;
while (a < b)
{
while (num1[a] == 0 && a < b)
a++;
while (num1[b] == 1 && a < b)
b––;
if (a < b)
{
num1[a] = 0;
num1[b] = 1;
a++;
b––;
}
}
}

int main()
{
int num[] = {1, 0, 1, 0, 1, 0, 1, 1, 0};
int z = 9, x = 0;
abc(num, z);
for (x = 0; x < 9; x++)
printf("%d ", num[x]);
getchar();
return 0;
}

a. 1 0 1 0 1 0 1 0 1
b. 1 1 0 0 1 1 0 0 1
c. 0 0 0 0 1 1 1 1 1
d. 1 1 1 1 1 0 0 0 0

The following program is based on a recursive algorithm. Analyze the code and choose the correct output from the given options.
#include<stdio.h>
main( )
{ static int a,f;
a=5.2; f=1;
f = res( a ) ;
f++;
printf ( "%d", f++ ) ;
}
res ( int x )
{ static int f ;
if ( x == 1 )
return ( 1 ) ;
else
f = x/4.5 + x + res ( x – 1 ) + 2 ;
return ( f++ ) ;
}

a. 21
b. 22
c. 25
d. 27

The declaration int (*p)() means:

a. p is an array of pointers to functions the return type of which is an integer
b. p is a pointer to a function that returns a pointer to an integer
c. p is a pointer to an array of integers
d. p is a pointer to an array of integer pointers
e. p is a pointer to a character string

Which of the following statements are correct about watchdog timers?
i) All watchdog timers can only be programmed for a single time-out delay at a time.
ii) When watchdog timers time-out, they may either reset the processor or execute an interrupt.
iii) The hardware implementation of a watchdog timer depends on the processor.

a. Only statements i) and ii) are correct.
b. Only statements ii) and iii) are correct.
c. Only statements i) and iii) are correct.
d. All statements i), ii) and iii) are correct.

Which of the following bits are used in the Interrupt Enable Register 1 (IE1) of the watchdog timer register?

a. NMI interrupt enable (NMIIE)
b. Watchdog timer interrupt enable (WDTIE)
c. NMI interrupt flag (NMIIFG)
d. Watchdog timer interrupt flag (WDTIFG)

In relation to watchdog timer registers, which of the following is the correct bit range used by WDTPW (watchdog timer password)?

a. Bits 7-3
b. Bits 9-4
c. Bits 11-7
d. Bits 15-8

What is the checksum size (width) for CCITT algorithm?

a. 8 bits
b. 16 bits
c. 32 bits
d. 64 bits

Which of the following options is used for reusing the 16-bit pseudo index register, __longIX, created earlier by the compiler?

a. long int exampleVar @ _ _longIX;
b. long int @ _ _longIX, exampleVar;
c. long int exampleVar \$ _ _longIX;
d. long int \$ _ _longIX, exampleVar;

In relation to the embedded C malloc() function, which of the following is the correct syntax for defining a header block with name hExample?

a. typedef struct Header hExample {
struct *ptr;
unsigned int size;
}
b. typedef hExample {
struct *ptr hExample;
unsigned int size;
} HEADER;
c. typedef struct hExample {
struct hExample *ptr;
unsigned int size;
} HEADER;
d. None of the above.

What would be printed on the standard output as a result of the following code snippet?
char i = 'A';
char *j;
j = & i;
*j = *j + 32;
printf("%c",i);

a. An error will occur
b. a
c. A
d. b
e. c

In the Harvard architecture of computers, how many data buses are used for accessing data and instructions?

a. Only one.
b. Only Two.
c. Two or more.

Choose the correct methods/techniques from the following options that can be used to design algorithms.
1. Divide and conquer
2. Greedy method
3. Back tracking
4. Branch and bound

a. Only 1 and 2
b. Only 1, 2 and 3
c. Only 1, 2 and 4
d. 1, 2, 3 and 4

Consider the following code.
int i = 4, *j, *k;
Which one of the following statements will not work?

a. j = &i;
b. j = j + 4;
c. j = j - 2;
d. k = j + 3;
e. j = j * 2;

In relation to National Semiconductor COP888 assembly language, which of the following is the correct syntax of the instruction that is used for executing the next instruction, on the condition that the bit 6 of register B is 1?

a. IFBIT 06,[B]
b. IFBIT 1,[B,06]
c. IFBIT 06,[1,B]
d. IFBIT 1,06,[B]

This question is based upon the figure shown below
Which of the given images represents a correct binary search tree, if the elements are inserted in the following order?
6, 31, 3, 41, 26, 5

a. 1
b. 2
c. 3
d. None of the above

In relation to the watchdog timer register (WDTCTL), which of the following values for WDTISx bits signifies watchdog clock source, /512?

a. 00
b. 01
c. 10
d. 11

What function will the following code perform?
void delete_element ( node *m, int n)
{
node *p, *k;
k = search ( m, n);
if (k = = ( node *) NULL)
return;
p = k –> next;
k –>next = p –>next;
free (p);
}

a. It will delete an element from the beginning of the list.
b. It will delete an element from the end of the list.
c. It will delete the element that is next to a given element in the list.

In relation to watchdog timer operations, setting the WDTTMSEL bit to which of the following options results in selecting the interval timer mode?

a. 0
b. 1
c. 2
d. 11

Which of the following statements is/are valid and correct?
1.char amessage[] = "lmnop";
amessage++;
2.char *pmessage = "abcde";
(*pmessage)++;
3.char amessage[] = "lmnop";
(*amessage)++;
4.char *pmessage = "abcde";
pmessage++;

a. 1234
b. 23
c. 24
d. 14
e. 34

This question is based upon the figure shown below
The given program, which was supposed to give output as shown in the image, has some errors. Analyse the code and choose the correct line number(s) containing error(s).
1.int main( )
2.{ int i=1,j=1,k=1;
3.    abc(i,j,k);
4.    xyz(i,j,k);
5.    return 0;
6.}
7.abc (int a, int b, int c)
8.{ for(;a<=5;a++)
9.    { for(b=5;b>a;b--)
10.        { printf(" "); }
11.        for(c=1;c<=a;c++)
12.        { printf("* "); }
13.        print("\n");
14.    } }
15.xyz(int *a, int *b, int *c)
16.{ for(a=4;a>=1,a--)
17.    { for(b=4;b>=a;b--)
18.        { printf(" "); }
19.        for(c=a;c>=1;c++)
20.        { printf("* "); }
21.        printf("\n");
22.    } }

a. 4
b. 9
c. 13
d. 14
e. 15
f. 16
g. 17
h. 19

Given the array:
int num= {
{3,6,9,12},
{15,25,30,35},
{66,77,88,99}
};
what would be the output of *(*(num+1)+1)+1?

a. 3
b. 15
c. 26
d. 66
e. 77

Which of the following divisors (polynomial) is used by the cyclic redundancy check algorithm CRC16?

a. 0x8005
b. 0x1021
c. 0x8801
d. 0x2100

What is the erase size for the EPROM memory?

a. byte.
b. sector.
c. Entire chip.
d. None of the above.

Which of the given functions will be performed by the following program?
#include <stdio.h>
void main()
{
int arr1;
int a, b, number1, tmp_no;
printf("Enter any value between 2 and 15\n");
scanf("%d", &number1);
printf("Enter elements\n");
for (a = 0; a < number1; a++)
{
scanf("%d", &arr1[a]);
}
for (a = 0; a < number1; a++)
{
for (b = 0; b < (number1 – a – 1); b++)
{
if (arr1[b] > arr1[b + 1])
{
tmp_no = arr1[b];
arr1[b] = arr1[b + 1];
arr1[b + 1] = tmp_no;
}
}
}
for (a = 0; a < number1; a++)
{
printf("%d\n", arr1[a]);
}
}

a. It will sort and print the array in the ascending order, by using the merge sort.
b. It will sort and print the array in the ascending order, by using the selection sort.
c. It will sort and print the array in the ascending order, by using the bubble sort.
d. It will sort and print the array in the ascending order, by using the quick sort.

Given the array:
int num=
{
{3,6,9,12},
{15,25,30,35},
{66,77,88,99}
};
what would be the output of *(*(num+1))?

a. 3
b. 15
c. 66
d. 6
e. 25

Analyse the following code and choose its correct output from the given options.
#include<stdio.h>
int main()
{
int num1 = {3,2,3,4,5,2,3,9,2};
int *pt1, sm=0;
int a, b, p, z, n=9;
z = n;
pt1 = num1;
for (a = 0; a < z; a++)
{
for (b = 0; b < z; b++)
{
if (a == b)
{
continue;
}
else if (*(pt1 + a) == *(pt1 + b))
{
p = b;
z--;
while (p < z)
{
*(pt1 + p) = *(pt1 + p + 1);
p++;
}
b = 0;
}
}
}
for (a = 0; a < z; a++)
{
sm=sm+num1[a];
}
printf("%d",sm);
return 0;
}

a. 22
b. 23
c. 24
d. 25

How many memory spaces and data buses are used by the Von Neumann architecture?

a. One common memory space and one data bus.
b. One common memory space and two data buses.
c. Two memory spaces and one data bus.
d. Two memory spaces and two data buses.

If a full binary tree has a total of 63 nodes, then what will be the numbers of the internal nodes and the leaves, respectively, in the binary tree?

a. 31 and 32
b. 34 and 29
c. 33 and 30
d. 28 and 35

In relation to the watchdog timer register (WDTCTL), what will happen if the value of WDTCNTCL bit is set to 1?

a. No action will be performed.
b. It will clear the count value to 0000h.
c. It will set the count value to 1000h.
d. It will stop the watchdog timer.

What would be printed on the standard output as a result of the following code snippet?
main()
{
char *pmessage = "asdfgh";
*pmessage++;
printf("%s", pmessage);
return 0;
}

a. Will result in Compilation Error
b. Undefined string
c. sdfgh
d. asdfgh

What will happen if in data structure a pop operation on the stack causes the stack pointer to move past the origin of the stack?

a. Overflow
b. Underflow
c. Null
d. Garbage collection

In relation to system reset and initialization, which of the following options can trigger the Power-Up Clear (PUC) signal?
i) The Power-On Reset (POR) signal.
ii) Security key violation of a flash memory.
iii) Security key violation of a watchdog timer.
iv) Expiration of a watchdog timer when in the watchdog mode only.

a. Only options i) and iii).
b. Only options i), ii) and iii).
c. Only options i), iii) and iv).
d. All options i), ii), iii) and iv).

What would be the output of the given C program?
int main( )
{
int a = 10, b = 20, m = 47, n = 96 ;
abc ( &a, &b ) ;
wxy ( &m, &n);
printf ( "%d, %d, %d, %d", a, b, m, n ) ;
return 0;
}
abc( int *x, int *y )
{
int t ;
t = *x ;
t = xyz();
*x = *y ;
*y = t++ ;
}
wxy(int *p, int *q)
{
*p = *p/2+9-1;
*q = *p/2+71-2;
}
xyz()
{
int t;
t = 6/2-54/3-(5.6/4);
return(t);
}

a. 20, 10, 25, 64
b. 20, -16, 31, 84
c. 10, -20, 57, 35
d. 10, -16, 20, 21
e. 12, -16, 11, 24

What will be the output of the following code?
#include <stdio.h>
void main()
{
int p=5, a, j, k, t, b;
int num[]={1,2,3,4,6};
b = num;
for (a = 1; a < p – 1; a++)
b = b ^ num[a];
for (a = 2, k = 1; a <= p; a++)
k = k ^ a;
k = k ^ b;
printf("%d", k+(k*18)+3);
}

a. 60
b. 79
c. 98
d. 117

In embedded C, which of the following functions is used for initializing the free-space pointer for indicating the first available byte of heap space?

a. malloc()
b. i_alloc()
c. calloc()
d. free()

In relation to watchdog timer registers, the WDTPW (watchdog timer password) is always read as which of the following options?

a. 05Ah
b. 06Ah
c. 069h
d. 059h

In relation to Interrupt Enable Register 1 (IE1) of the watchdog timer register, which of the following bits can be used by other modules?

a. Bits 3-1
b. Bits 5-2
c. Bits 7-5
d. Bits 7-4

In relation to Interrupt Enable Register 1 (IE1) of the watchdog timer register, NMI interrupt enable (NMIIE) bit is recommended to be set and cleared using which of the following instructions?

a. BIS.B
b. BIC.B
c. MOV.B
d. CLR.B

Which of the given types of memories has the following characteristics?
i) It requires a block-sized 'erase' operation before this type of memory can be programmed.
ii) It is used for the storage of a program code.

a. EEPROM
b. Flash ROM
c. UV EPROM
d. PROM

Which of the following memory types has fast relative speed?

a. SRAM
b. EEPROM
c. PROM
d. Masked ROM

Find the output of the following program and choose the correct answer from the given options.
#include <stdio.h>
#include <malloc.h>
void abc(int num2[], int num)
{
int *c = (int *)calloc(sizeof(int), (num – 2));
int i;
printf("output: ");
for (i = 0; i < num; i++)
{
if (c[num2[i]] == 1)
printf(" %d ", num2[i]+5);
else
c[num2[i]]++;
}
}
int main()
{
int num1[] = {15, 10, 10, 2, 7, 4, 2};
int af = sizeof(num1) / sizeof(num1);
abc(num1, af);
getchar();
return 0;
}

a. output: 15 4
b. output: 15 7
c. output: 10 7
d. output: 10 2

This question is based upon the figure shown below
Choose from the given image, the correct output of the following code.
#include<stdio.h>
main ()
{
int x, y;
abc(x);
xyz(x,y);
printa(y);
}
abc(m)
int m[];
{
int i, j;
for(i=0;i<3;i++)
{for (j=0; j<3;j++)
{m[i][j]=((i+2) + (j+3));
}}
}
xyz(x,y)
int x[], y[];
{
int i, j;
for(i=0;i<3;i++)
for (j=0;j<3;j++)
{
y[j][i]=x[i][j];
}
}

printa(m)
int m[];
{
int i,j;
for(i=0;i<3;i++)
{
for (j=0; j<3;j++)
printf("%d ", m[i][j]);
printf("\n");
}
}

a. (1)
b. (2)
c. (3)
d. (4)

Which of the following memory types is neither volatile nor writable?

a. SRAM
b. DRAM
c. Masked ROM
d. Flash

In relation to embedded C memory management, which of the following are incorrect minimum requirements for dynamic memory allocator?

a. The free() function must prevent the fragmentation of freed memory.
b. The order of calls to free() function must be exactly reverse of the order of calls to malloc().
c. If no memory is available, an error condition must be returned.
d. Overhead in memory need not to be minimized.

In relation to embedded C, which of the following data types is used for accessing the bit addressable memory of RAM (20h-2fh)?

a. sbit
b. bit
c. SFR
d. None of the above.

What will be the output of the given program?
#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node *next;
};
void ab(struct node* head)
{
if(head == NULL)
return;
ab(head–>next);
printf("%d ", head–>data*12);
}
void de(struct node* start)
{
if(start == NULL)
return;
printf("%d ", start–>data);
if(start–>next != NULL )
de(start–>next–>next);
printf("%d ", start–>data*7/6);
}
void p(struct node** head_ref, int new_data)
{
struct node* new_node =(struct node*) malloc(sizeof(struct node));
new_node–>data = new_data;
new_node–>next = (*head_ref);
(*head_ref) = new_node;
}
int main()
{
struct node* head = NULL;
p(&head, 15);
p(&head, 333);
p(&head, 31);
p(&head, 21);
p(&head, 17);
ab(head);
de(head);
getchar();
return 0;
}

a. 180 3996 372 252 204 67 45
b. 15 333 31 21 17 31 15 21 333 17
c. 180 3996 372 252 204 17 31 15 17 36 19
d. 15 333 31 21 17

In relation to microcontrollers, which of the following types of buses is/are bi-directional?

a. Address bus.
b. Data bus.
c. Both options a and b.
d. Neither option a nor b.

What will be the output of the following program?
#include <stdio.h>
struct st1
{
int a;
struct st1 *ptr1 ;
};
main( )
{
struct st1 w1,w2;
w1.a = 251 ;
w2.a = 351 ;
w1.ptr1 = &w2 ;
w2.ptr1 = &w1 ;
printf ( "%d %d", w1.ptr1 –> a, w2.ptr1 –> a ) ;
}

a. 251 251
b. 351 351
c. 251 351
d. 351 251

What will be the output of the following code?
#include <stdio.h>
#include <stdlib.h>
struct nd
{
int x;
struct nd* byn;
struct nd* dyn;
};
unsigned int abc(struct nd* nd)
{
if(nd == NULL)
return 0;
if(nd–>byn == NULL && nd–>dyn==NULL)
return 1;
else
return abc(nd–>byn)+abc(nd–>dyn);
}
struct nd* wnd(int x)
{
struct nd* nd = (struct nd*)
malloc(sizeof(struct nd));
nd–>x = x;
nd–>byn = NULL;
nd–>dyn = NULL;
return(nd);
}
int main()
{
struct nd *p = wnd(1);
p–>byn = wnd(2);
p–>dyn = wnd(3);
p–>byn–>byn = wnd(4);
p–>byn–>dyn = wnd(5);
printf("%d", abc(p));
getchar();
return 0;
}

a. 1
b. 2
c. 3
d. 4

Which of the following statements is/are false about a pointer?

a. A pointer allows to pass variables, strings, functions, arrays, and structures as function arguments.
b. A pointer provides functions that can modify their calling arguments.
c. A pointer variable holds the value as well as the memory address of another variable.
d. A pointer does not allow to return structured variables from functions.
e. A pointer supports dynamic allocation and de-allocation of memory segments.

In microcontroller 8051 with 256 bytes of RAM, what is the amount of memory provided to SFR registers?

a. 64 bytes
b. 128 bytes
c. 192 bytes
d. 32 bytes

Which of the following are types of hardware interrupts?

a. Timer overflow
b. Signal to pin
c. Serial port interrupts
d. SWI instruction

Which of the following watchdog timer registers are of read/write type?
i) Watchdog timer control register
ii) Timer_A interrupt vector register
iii) SFR interrupt enable register 1
iv) SFR interrupt flag register 1

a. Only options i) and ii).
b. Only options i), ii) and iv).
c. Only options i), iii) and iv).
d. All options i), ii), iii) and iv).

Which function returns the current pointer position within a file?

a. ftell()
b. fseek()
c. fgetc()
d. fread()
e. fscanf()

Which of the following statements is/are false?

a. Array elements can be accessed through pointers because they are stored in contiguous memory locations.
b. A compiler always performs bounds checking on an array.
c. An array variable acts as a pointer to its base address in memory.
d. A pointer, when incremented, always points to the next location of its type.

In relation to watchdog timer register (WDTCTL), which of the following bits is used for selecting the watchdog timer interval for setting the WDTIFG flag and/or generating a PUC?

a. WDTSSEL
b. WDTTMSEL
c. WDTCNTCL
d. WDTISx

What is the size of each header block for systems having two-byte memory pointers and available memory less than 64 bytes?

a. 8 bytes
b. 16 bytes
c. 4 bytes
d. 2 bytes
e. 1 byte

Which of the following statements are correct about the embedded system, TIMER interrupt?

a. Access to external clock is provided by TIMER interrupts.
b. An overflow occurs when timer goes from 0000 0000 to 1111 1111.
c. A watchdog can be built using TIMER interrupts.

In relation to watchdog timer modification, which of the following statements is/are correct?
i) Before changing the clock source, the WDT should be halted to avoid a possible incorrect interval.
ii) User should not change the WDT interval along with WDTCNTCL = 1 in a single instruction for avoiding an unexpected interrupt.

a. Only statement i) is correct.
b. Only statement ii) is correct.
c. Both statements i) and ii) are correct.
d. Neither statement i) nor ii) is correct.

This question is based upon the figure shown below
Which of the following is the post–order traversal of the binary tree that is given in the image?

a. O M S P N T Q R U L
b. O S P M T Q U R N L
c. O T U Q R S O M N L
d. O P S T Q U R M N L

In relation to byte-orientation memory of an 8051 microprocessor, what is the content of the 0x03 address?

a. 00111100
b. 00011100
c. 01011010
d. 00110010

How many binary trees can be formed using three nodes?

a. 8
b. 5
c. 7
d. 6

Analyse the given code and answer the following question.
#include <stdio.h>
int main()
{
typedef char (*(*abc)());
abc a1;
return 0;
}
Which of the following is true about 'a1'?

a. It is a pointer.
b. It is an array of four function pointers.
c. It is an array of four pointers.
d. There is an error in the declaration of a1.

What is the output of the following program ?
main()
{

int u = 1, v = 3;
printf("%d %d",u,v);
funct1(&u,&v);
printf(" %d %d\n",u,v);
}

void funct1(int *pu, int *pv)
{
*pu=0;
*pv=0;
return;
}

a. 1 3 1 3
b. 1 3 1 1
c. 1 3 0 0
d. 1 1 1 1
e. 3 1 3 1

In relation to endianness problem, which of the following pre-processor macros is used for reordering the bytes of a 16-bit unsigned value from network order to processor order?

a. htonl( )
b. htons( )
c. ntohl( )
d. ntohs( )

Which of the following is a linear list in which we can insert/delete element(s) at either end but not in/from the middle?

a. Tree
b. Queue
c. Stack
d. Dequeue

Which of the given types of memories has the following characteristics?
i) It requires a block-sized 'erase' operation before this type of memory can be programmed.
ii) It is used for the storage of a program code.

a. EEPROM
b. Flash ROM
c. UV EPROM
d. PROM

Choose the correct output of the following C program.
int main()
{
int i,k;
i=5;
k=abc(i);
printf("%d",k);
return 0;
}
int abc(int a)
{
int b,c,d,e;
b=6;c=9;a=a/2;
d=xyz(b);
e= d+b-(c/d)+1.5;
return(e);
}
int xyz(int w)
{
int p=1;
do
{
p=p*w;
w--;
}
while(w>0);
return(p);
}

a. 675
b. 547
c. 720
d. 634
e. 727

Which of the following values of the WDTHOLD bit of watchdog timer register (WDTCTL) specifies that the watchdog timer has stopped?

a. 0
b. 1
c. NULL

Which of the following statements are correct about the WDTCTL register?

a. It is 8 bit.
b. It is password-protected.
c. It is a read-only register.
d. It contains control bits for configuring the RST/NMI pin.

Choose the correct output of the following C program.
int main( )
{
int i = 3, j = 4, k, l ;
k = abc ( i, j ) ;
l = abc ( i, j ) ;
k=k+3;
l=l+3;
printf ( "%d %d", k, l ) ;
return 0;
}
abc ( int ii, int jj )
{
int kk, ll ;
kk = ii + jj+3 ;
ll = ii * jj+2 ;
return ( kk, ll ) ;
}

a. 10, 14
b. 13, 17
c. 13, 13
d. 17, 17
e. Compilation error

Which of the following options is the output of the given program?
int main( )
{
int a=8.5, f=1 ;
f = res( a ) ;
f++;
printf ( "%d", f++ ) ;
return 0;
}
res ( int x )
{
int f=1 ;
if ( x == 1 )
return ( 1 ) ;
else
f = f/4.5 + x * res ( x - 1 ) ;
return ( f++ ) ;
}

a. 40,320
b. 40,321
c. 40,322
d. 40,323
e. It will give an error.

Find the output of the following code and choose the correct answer from the given options.
#include <stdio.h>
int funct1(int num1[], int num2[], int n)
{
int x1 = 0;
int x2 = 0;
int total;
int k1 = –1, k2 = –1;
for (total = 0; total <= n; total++)
{
if (x1 == n)
{
k1 = k2;
k2 = num2;
break;
}
else if (x2 == n)
{
k1 = k2;
k2 = num1;
break;
}
if (num1[x1] < num2[x2])
{
k1 = k2;
k2 = num1[x1];
x1++;
}
else
{
k1 = k2;
k2 = num2[x2];
x2++;
}
}
return (k1 + k2)/2;
}
int main()
{
int num1[] = {22, 27, 34, 31, 39};
int num2[] = {22, 54, 67, 74, 46};

int p1 = sizeof(num1) / sizeof(num1);
int p2 = sizeof(num2) / sizeof(num2);
if (p1 == p2)
printf("%d", funct1(num1, num2, p1));
else
printf("failure");
return 0;
}

a. 32
b. 33
c. 34
d. 35

Embedded C Test Upwork 2019