Skip to main content

C and Assembly Questions and Answers 101

 

Assembly and C Questions 101:

1. How long will it take for a 128kB file to go across at 1Mbps?

2. DMA full form?

3. Register: Register is the fastest memory in a computer which holds information. True or False

4. A 32-bit processor means it can perform operations on 32-bit data; therefore, the size of registers is 32 bits and ALU also performs 32-bit operations. A 64-bit CPU performs the operation in 64-bit data; therefore, it contains 64-bit register and 64-bit ALU. 

True or False

5. Which of the following is a control signal?

a.      Read Signal

b.     Write Signal

c.      Interrupt

d.     Bus Request

e.      Bus Grant

f.      I/O Read and Write

g.     All of the above

6. There are two types of CPU technology CISC and RISC. What is the full form of CISC and RISC?

7. The characteristics of 8086 are called reduced instruction set computers (RISC)?

True or False

8. What are the two types of CPU architecture?

9. Von Neumann uses the data bus to transfer data and instructions from the memory to the CPU whereas Harvard architecture uses separate buses for instructions and data.

 True or False

10. Define Clock Speed?

11. Cache memory is a small amount of high-speed memory used for temporary data storage based between the processor and main memory.

True or False

12. What is the full form of SIMD technique used in MMX technology?

13. How many general-purpose registers 8085 has and what are they?

14. What is the full form of BCD?

15. Fill in the full form of the acronym presented in the diagram below for flag register?

S

Z

------

AC

------

P

------

CY

16. Name 3 special purpose register in 8085?

17. What are the two 16-bit registers used to hold memory addresses?

18. When a byte (machine code) is being fetched, the program counter is incremented by one to point to the next memory location? True or False

19. Program Counter holds the address of the last program request in a stack whereas Stack Pointer holds the address of the next instruction that should be executed?

True or False

20. The stack is usually retrieved in a LIFO fashion.

True or False

21. Which of the following is not one of the 5 addressing modes of intel 8085 microprocessor?

A.    Direct Addressing Mode

B.    Register Addressing Mode

C.    Register Indirect Addressing Mode

D.    Immediate Addressing Mode

E.     Explicit Addressing Mode

F.     Implicit Addressing Mode

22. Which of the following is the instruction group of Intel 8085 microprocessor?

A.    Data Transfer Group

B.    Arithmetic Group

C.    Logical Group

D.    Branch Control Group

E.     I/O and Machine Control Group

F.     All of the above

23. How many bit is 8085 microprocessor and 8086 microprocessor?

24. What does BIU and EU stand for?

25. What are the two separate functional units of 8086 architecture?

26. 8086 architecture employs parallel processing?

True or False

27. 8086 has an instruction queue, which is capable of storing six instruction bytes from the memory resulting in faster processing. True or False

28. What are the two stages of pipelining 8086 microprocessor uses?

29. The Bus Interface Unit(BIU) contains four 16-bit special purpose registers called as Segment Registers. What are their names?

30. What is the full form of ISR?

31. What is the block of memory reserved(1Kb) for storing the starting addresses of interrupt service routines in 8086 system called?

32. What are the three techniques of mapping between main memory and cache?

33. Which is the fastest and most flexible mapping between cache and main memory?

34. What is the full form of DRAM and SRAM?

35. DRAM is used for cache memory and SRAM is used for main memory? True or False

36. What does opcode stand for?

 C Questions

37. What is scanf used for?

38. What does %d and & operator mean in C?

39. We cannot declare a variable without specifying its data type? True or False

40. A variable in  C can be altered or its value can be changed, but same is not true for its type. True or False

41. In C int can store only 2 bytes worth of data as its storage capacity is 2 bytes while float storage capacity is 4 bytes. True or False

42. What are the four data types in C ?

43. What are the three logical operators in C ?

44. What does these symbols indicate ?

&&, ||, ! !=

45. There are how many keywords in C ?

 

46. The length of the identifiers should not be more than 24 characters in C ? True or False

47. The Format specifier is a string used in the formatted input and output functions. What %d, %i,%ld,%c ,%sand %u are used for?

48. What do the following escape sequences stand for ?

\a, \b, \r, \0, \n

49. What is the full form of ASCII ?

50. WHAT IS “&” AND “*” OPERATORS IN C?

51. What are the two ways to define constant in C programming ?

52. As we know that non-static functions are global by default means that the function can be accessed outside the file also, but if we declare the function as static, then it limits the function scope. The static function can be accessed within a file only. True or False

53. What are the 5 programming errors in C?

54. What is syntax error also known as?

55. Linker errors are mainly generated when the executable file of the program is not created, like for example using Main() instead of main(). True or False

56. Write a syntax for if Statement in C?

57. if else-if ladder statement is similar to the switch case statement. True or False

58. Which Data Type Cannot Be Checked In Switch-Case Statement?

a.      enum  b. character c. integer d. float

59. What are the three types of loops in C language?

60. Typecasting allows us to convert one data type into other. In C language, we use cast operator for typecasting which is denoted by (type). True or False

61. What is goto statement is also known as in C?

62. The only condition in which using goto is not preferable is when we need to break the multiple loops using a single statement at the same time. True or False

63. What does ceil(), floor() do in C?

64. There are 2 types of function in C, library functions and user-defined functions. Printf(), gets(), puts(), ceil(), floor() belong to which category.

65. All string related library functions like gets(), puts(),etc. are in which header file?

66. What is conio.h for?

67. Which header file contains all the general library functions like malloc(), calloc(), exit(), etc.

68. What does gets() do in C?

69. What is the purpose of gets () and puts () function?

70. Is space accepted as a character in gets()?

71. What are the alternative functions to gets()?

72. Which header file contain functions like malloc(), calloc(), exit()?

73. In call by value method, we can modify the value of the actual parameter by the formal parameter. True or False

74. In call by reference, the address of the variable is passed into the function call as the actual parameter. True or False

75. Spatial locality: states that recently accessed items are likely to be accessed in the near future.

Temporal locality says that items whose addresses are near one another tend to be referenced close together in time. True or False

76. Is i ++ the same as i += 1 ?

77. i++ known as Post Increment whereas ++i is called Pre Increment, are they the same?

78. We can store pointers into the register, i.e., a register can store the address of a variable. True or False

79. There are four types of storage classes in C. What are they?

80. What are the two types of buffer overflow vulnerabilities?

81. Stack is the memory space used by the operating system and heap is the memory space used to store dynamic data which is managed by the program. True or False

82. The data on the stack is stored and retrieved in an organized fashion(first-in-last-out). True or false

83. What is strcmp() in C

84. What is an Array in C?

85. Strings are actually a one-dimensional array of characters terminated by a null character '\0'. True or False

86. Since, puts() prints an additional newline character with the string, which moves the cursor to the new line on the console, the integer value returned by puts() will always be equal to the number of characters present in the string plus 1.True or False

87. What is the function of strlen() ?

88. What is the function of strstr()?

89. What is a pointer in C?

90. What is a double pointer?

91. For 32-bit and 64 bit architecture, by how may bytes the pointer is incremented and decremented respectively?

92. What is a dangling pointer?

93. Dynamic memory allocation in C language is possible by 4 functions of stdlib.h header file. What are those 4 functions?

94. In static memory, memory is allocated at run time and in dynamic memory, memory is allocated at compile time. True or False.

95. What are the functions of malloc() & calloc()?

96. What are the functions of free() and realloc()

97. What is a Enum in C?

98. What is getch() in C?

99. What is heap area in data segment used for?

100. What are the four different parts of data segment(special memory segment) in C?

101. What are the two types of files one should know about in C?

Answers

1.      1 sec

2.      Direct Memory Access

3.     True

4.     True

5.     G- All of the above.

6.     Complex Instruction Set Computer and Reduced Instruction Set Computer

7.     False (In fact, 8086 is based on CISC)

8.     Von Neumann Architecture and Harvard Architecture

9.     True

10.  The speed of the clock determines the speed at which the processor executes instructions.

11.  True

12.  Single Instruction Multiple Data

13.  8085 has 6 general-purpose registers to store 8-bit data. They are B, C , D , E, H and L. These can be combined as register pairs BC, DE and HL

14.  Binary-Coded Decimal

15.  Flag Register:

Sign Flag(most significant bit)

Zero Flag

-------

Auxiliary

Carry Flag

--------

Parity Flag

-------

Carry Flag

16.  Accumulator (also defined as register A is the part of ALU), Flag register/Status register and Memory registers.

17.  Program Counter and Stack Pointer

18.  True

19.  False (It is vice versa instead. Program counter also called instruction counter holds the address of the next instruction that should be executed and stack pointer holds the address of the last program request in a stack.)

20.  True – (LIFO stands for Last in first out.)

21.  E – Explicit Addressing Mode

22.  F – All of the above

23.  8085 microprocessor: 8-bit (8-bit data bus, 16-bit address bus which can address up to 64KB)

8086 microprocessor: 16-bit (16-bit data bus, 20-bit address bus, can access up to 1Mb of memory.)

24.  BIU – Bus Interface Unit

EU – Execution Unit

25.  BIU – Bus Interface Unit and

EU – Execution Unit

26.  True

27.  True

28.  Fetch stage and Execute stage

29.  Direct Mapping, Associative Mapping and Set Associative Mapping.

30.  Data Segment Register(DS), Code Segment Register(CS), Stack Segment Register(SS), Extra Segment Register(ES)

31.  Interrupt service routine

32.  Interrupt vector table or Interrupt pointer table

33.  Associative Mapping

34.  Dynamic Random Access Memory and Static Random Access Memory

35.  False (DRAM for main memory and SRAM for Cache memory, (dynamic refers to the tendency of the stored charge to leak away, even with power continuously applied whereas SRAM will hold its data as long as power is supplied to it.))

36.  Operation Code

37.  scanf is used to take input from the users.

38.  %d is a format specifier notifies the value should be of integer type(decimal integer) and & operator is used to get the address of the variable.

39.  True

40.  True

41.  True

42.  BVED – Basic Data Type (int, char, float, double), Void Data Type (void), Enumeration Data Type (enum) and Derived Data type (array, pointer, structure, union – aups)

43.  AND, OR and NOT

44.  && - AND operator, || - OR operator, ! = Not Operator, != is not equal to

45.  32

46.  False. The length of the identifiers should not be more than 31 characters

47.  %d/%i – It is used to print the signed integer value –(signed -both positive and negative values)

%ld – It is used to print long signed integer values.

%c-It is used to print the unsigned character.

%c – It is used to print the strings.

%u – It is used to print unsigned integer value.

48.  \a –Alarm or Beep, \b – backspace. \r -Carriage return, \0 – Null,

 \n – New line

49.  American Standard Code for Information Interchange

50.  “*” Operator is used as pointer to a variable. Example: * a where * is pointer to the variable a.

& operator is used to get the address of the variable. Example: &a will give address of a.

51.  const keyword and #define preprocessor

52.  True

53.  Syntax error

Run-time error

Linker error

Logical error

Semantic error

54.  Compilation errors

55.  True

56.  if <expression>{

//code to be executed

} --------Eg.

int main()

int number=0;

printf(“Enter a number”);

scanf(“%d”, &number);

if(number%2==0{

printf(“%d is even number”, number);

}

57.  True

58.  d. float

59.  do while(post tested loop), while(pre tested loop), for

60.  True

61.  The goto statement is known as jump statement in C.

62.  False (It is indeed preferable)

63.  The ceil function returns the smallest integer that is greater than or equal to x (ie: rounds up the nearest integer)-(tip – think ceiling). The floor function returns the largest integer that is smaller than or equal to x (ie: rounds downs the nearest integer)-(tip – think floor).

Ex- Enter a float value: 123.45

    floor value:123.000000

    ceil value:124.000000

64.  Library functions

65.  string.h. (The gets() and puts() are declared in the header file stdio.h)

66.  This is a console input/output header file.

67.  Stdlib.h

68.  The gets() function enables the user to enter some characters followed by the enter key. All the characters entered by the user get stored in a character array.

69.  The gets() functions are used to read string input from the keyboard and puts() function displays it.(Tip-gets() similar to scanf() and puts() similar to printf())

70.  Yes (scanf do not accept space as character).

71.  Fgets() and getline().

72.  stdlib.h

73.  False. (In call by value method, we can not modify the value of the actual parameter by the formal parameter.)

74.  True

75.  False ( It is vice versa – Spatial links with space, and temporal with time)

76.  Yes

77.  No - i++ is post increment because it increments i's value by 1 after the operation is over. ++i is pre increment because it increments i's value by 1 before the operation.

int i = 1, j;

j = i++; --------------à j=1 but i=2

j=++i; ----------------à j=2 and i=2.

78.  True

79.  Automatic, External, Static and Register.

80.  Stack overflow and heap overflow.

81.  True

82.  False The data on the stack is stored and retrieved in an organized fashion(last-in-first-out).

83.  The strcmp() function is used to compare two strings two strings str1 and str2 . If two strings are same then strcmp() returns 0 , otherwise, it returns a non-zero value. The function strcmp() is a built-in library function and it is declared in “string. h” header file.

84.  An Array is a data structure containing a number of data values(all of which are if same type). (Each data element in the array can be randomly accessed by using its index number).

85.  True

86.  True

87.  The strlen() function returns the length of the given string. It doesn't count null character '\0'.

88.  The strstr() function returns pointer to the first occurrence of the matched string in the given string.

89.  Pointer is a variable that contains the address(or memory address) of another variable. It can be declared using *symbol. A pointer is used to store the address of a variable in C.

90.  In C, we can also define a pointer to store the address of another pointer. Such pointer is known as a double pointer (pointer to pointer).

91.  For 32-bit int variable -incremented and decremented by 2 bytes.

For 64-bit int variable-incremented and decremented by 4 bytes.

(Same applies for C pointer addition and pointer subtraction -2*  number for 32-bit and 4*number for 64-bit)

92.  Pointer initialized with an invalid address is a dangling pointer. (Dangling pointer occurs at the time of the object destruction when the object is deleted or de-allocated from memory without modifying the value of the pointer.)

93.  malloc(), calloc(), realloc() and free()

94.  False. (Static memory is used in the array, memory is allocated at compile time and memory can’t be increased while executing the program. Dynamic memory is used in the linked list, memory is allocated at run time and memory can be increased while executing the program.)

95.  malloc() stands for memory allocation, it reserves a block of memory of the specified number of bytes.

calloc() stands for contiguous allocation, malloc() function allocates memory and leaves the memory uninitialized, whereas calloc() function allocates memory and initializes all bits to zero.

96.  free() – It frees the space allocated in the memory pointed by ptr.(sytax- free(ptr);)

realloc()- If the dynamically allocated memory is insufficient or more than required, you can change the size of previously allocated memory using the realloc() function.

97.  It is an enumeration type, user defined data type that consists of integer values.

98.  Predefined non standard function that is defined in conio.h header file. It is used to hold the output screen for some time until the user passes a key from the keyboard.(Using this function, we can hide the input characted provided by the users in the ATM PIN, password, etc.

99.  The heap area is used to store the data structures which are created by using dynamic memory allocation.

100.         Data area, Code area, Heap area, Stack area(Initialize variable and Non-initialize variable).

101.         Text files and binary files.

 

Thank you

 

 

 

 

 

 

 

Comments

Popular posts from this blog

Python Sample Questions and Answers for Beginners.

  Phython Sample Questions:   1.      In Python, a variable must be declared before it is assigned a value: a.      True b.      False c.      Non Applicable     2.     In Python, a variable may be assigned a value of one type, and then later assigned a value of a different type: a.True b.False 3.     Consider the following sequence of statements: n = 300 m = n Following execution of these statements, Python has created how many objects and how many references? a.      Two objects, two references b.      Two objects, one reference c.      One object, one reference d.      One object, two references 4.     What Python built-in function returns the unique number assigned to an object: a.      ref() b.      id() c.      refnum() d.      identity() 5.     Which of the following are valid Python variable names: a.      home_address b.      return c.      route66 d.      ver1.3 e.      Age f.        4square 6.     Which of the fol

IPV4, Class and Subnetting.

  IPV4, Class and Subnetting.   IPV4 which stands for Internet protocol version 4 consists of 32 bits. It is written in four octets (1 octet consists of eight bits) – xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx -----these digits are in binary either 1 or 0 and if written in decimal looks something like this – 10.25.58.65  The maximum value of 1 octet is 255 that is derived from- lets suppose if an octet is all 1s like 11111111 ---- the decimal value of this equals to 255. Lets get into few important points:   IPV4 class ---- Classes 1 st Octet Range Default Subnet Mask Finding Formula A 0-127 (#127 is a loop IP) 255.0.0.0 00000000(0) -011111111(127) (0 constant in the range) B 128-191 255.255.0.0 10000000(128) – 10111111(191) (10 constant ) C 192 -223 255.255.255.0 11000000(192) – 11011111(223)  (110 constant in the ran