We are one of the best embedded systems training institute for advance courses. We are the pioneer of the embedded system training in Pune & Pcmc with the expertise of over 16 years. we are working in the field training & development of embedded systems & currently we are also working on live projects as per the requirements of clients. though we provide many different courses & training in embedded all aim at giving good practical knowledge to students as well help them in their career.
1. 1. What is C Language?
The first programming language ever created, C, is a procedural programming language. It was
developed by Dennis Ritchie as an operating system programming language. Because of its structure,
high-level abstraction, machine independence, and other features, it is one of the most widely used
programming languages and a fantastic place to start for anyone interested in learning how to code.
2. What is the use of printf() and scanf() functions? Also explain format specifiers?
printf() is used to print the output on the display.
scanf() is used to read formatted data from the keyboard.
Some datatype format specifiers for both printing and scanning purposes are as
follows:
%d: It's a datatype format specifier for printing and scanning an integer value.
%s: It's a datatype format specifier for printing and scanning a string.
%c: It's a datatype format specifier for displaying and scanning a character
value.
%f: The datatype format specifier %f is used to display and scan a float value.
3. What is a built-in function in C?
Built-in functionality, usually referred to as library functions, is a convenience feature offered by
the system that helps developers complete a number of frequently performed predefined activities.
For instance, in C, we use printf() to print output or our programme into the terminal.
4. What is an r-value and l-value?
A data value that is kept in memory at a specific location is referred to as a "r-value". A value
cannot be assigned to an expression that has an r-value, hence this expression can only occur on the
right side of the assignment operator (=).
The phrase "l-value" describes a memory address that is used to identify an object. Either the
left or right side of the assignment operator (=) contains the l-value. In many cases, l-value is utilised
as an identification.
5. What is Dynamic memory allocation in C? Name the dynamic allocation
functions?
C is a language known for its low-level control over the memory allocation of
variables in DMA there are two major standard library malloc() and free. The malloc()
function takes a single input parameter which tells the size of the memory requested It
returns a pointer to the allocated memory. If the allocation fails, it returns NULL. The
prototype for the standard library function is like this:
void *malloc(size_t size);
The free() function takes the pointer returned by malloc() and de-allocates the
memory. No indication of success or failure is returned. The function prototype is like
this:
void free(void *pointer);
There are 4 library functions provided by C defined under <stdlib.h> header file to
facilitate dynamic memory allocation in C programming. They are:
malloc()
calloc()
free()
2. realloc()
6. What is the difference between #include "..." and #include <...>?
The C preprocessor initially checks the predefined list of system directories for
the filename for #include filename> before checking the user-specified directories
(directories can be added to the predetermined list using the -I option).
The preprocessor searches for #include "filename" in the same directory as the file containing
the directive first, then uses the same search path as for the #include filename> form. This approach is
typically used to include header files that are defined by programmes.
7. What is call by reference in functions?
Call by reference is the term used when the calling function calls a function
without using the addresses of the actual parameters being given. Because all actions
in incall by reference are conducted on the value stored in the address of real
parameters, each operation made on formal parameters has an impact on the value of
actual parameters.
8. What is a near pointer and a far pointer in C?
Near Pointer: The near pointer, which can hold an address with a maximum size
of only 16 bits, is generally regarded. The close pointer cannot be used to store an
address with a size greater than 16 bits. The 16-bit limit does not apply to any other
smaller addresses, therefore they can all be saved. You might suppose the 16 bits are
insufficient given that we can only read 64kb of data at once. It is no longer widely
employed because it is thought to be one of the near-pointer's main shortcomings.
Far pointer: A 32-bit pointer is regarded as being a far pointer. However, it can
make use of the current segment to access data kept outside of the computer's
memory. Although we typically need to allocate the sector register to store the data
address in the current segment in order to use this type of pointer.
9. Which structure is used to link the program and the operating system?
The operating system and a programme are joined by the file structure. The file is
defined by the "stdio.h" header file (standard input/output header file). It includes
details about the file now being used, including its size and placement in memory. It
includes a character pointer that directs the user to the character that is currently open.
When a file is opened, a connection is made between the programme and the operating
system so that they know which file will be accessed.
10 - Which is better #define or enum?
The compiler has the ability to create enum values automatically if we let it. The
defined values must all be provided separately, though.
The source code is not aware of these macros because they are preprocessors rather
than enums, which are compile-time entities. The enum is therefore preferable if we debug
the function with a debugger.
If we utilise enum values in a switch and the default case is absent, some compilers will
issue a warning.
Enum always produces identifiers of the int type. On the other hand, the macro gave us
the option to select among a number of integral types.
3. The macro lacks a clearly known scope constraint, unlike enum.
11- How do you override a defined macro?
The #ifdef and #undef preprocessors can be used as follows to replace a declared
macro:
#ifdef A
#undef A
#endif
#define A 10
If macro A is defined, it will be undefined using undef and then defined again using
define
12- What is dynamic data structure?
A dynamic data structure (DDS) is an arrangement or grouping of data in memory that
can expand or contract in size, giving a programmer complete control over how much
memory is used. As needed, unused memory from the heap is allocated or de-allocated to
adjust the size of dynamic data structures.
Programming languages like C, C++, and Java rely heavily on dynamic data structures
because they provide programmers the freedom to control how much memory a programme
uses.
13-Escape Sequence in C
The characters or sequence of characters that can be used inside a string literal in C are
known as the escape sequence. The characters that can't be typed regularly using the
keyboard are represented by the escape sequence. Some escape sequence symbols are
included in the ASCII charset, whereas others are not.
Characters are represented by different escape sequences, however the result depends
on the compiler you're running.
14- Function Prototype in C
The C function prototype is a statement that provides information to the compiler
about the function's name, return type, parameter values, and data types. The compiler
compares the data type of function parameters with the function declaration and function
call using this information.
Function prototypes function similarly to function declarations in that they are optional
if the function definition appears in the programme before the function call, but obligatory if
the function reference or call appears before.
15 – what are C/C++ Preprocessors
Programmes called preprocessors are used to clean up source code before compilation.
In C/C++, there are several phases between writing a programme and running it. Before we
begin learning about preprocessors, let's have a look at these stages.
4. To instruct the compiler to preprocess the source code before compiling, preprocessor
programmes offer preprocessor directives. The '#' (hash) sign is used at the start of each of
these preprocessor directives. The '#' symbol denotes that the preprocessor programme will
be used to execute any statement that begins with a '#'. These preprocessor directives can be
inserted anywhere in our programme.
16 - What do you mean by Dangling Pointer Variable in C Programming?
In C programming, a pointer is used to identify a variable's location in memory. The term
"dangling pointer variable" refers to a pointer variable that has been erased yet the pointer is
still referring to the same position in memory.
17 - Differentiate between calloc() and malloc()
The memory dynamic memory allocating routines calloc() and malloc(). The sole
distinction between them is that malloc() will not load a value into any of the designated
memory addresses, but calloc() would.
18 - How can we store a negative integer?
The procedures below must be taken in order to store a negative integer. Calculate the
same positive integer's two's complement.
Eg: 1011 (-5)
One's complement of 5 in Step 1 is 1010.
Step 2: Adding 1 to the above resulted in 1011, which is -5.
19 - Differentiate between Actual Parameters and Formal Parameters.
Actual parameters are those that are transmitted from the main function to the
subdivided function, while formal parameters are those that are specified at the subdivided
function conclusion.
20 - What is a C Token?
C Tokens are any keywords, constants, special symbols, strings, operators, or identifiers
used in a C programme.
21- What are the limitations of scanf() and how can it be avoided?
The following are scanf()'s restrictions:
The character string prevents scanf() from working.
The scanf() function cannot be used to insert a multiword string into a single variable.
The gets() method is utilised to prevent this.
When the enter key is pushed, it is terminated after receiving a string from the keyboard.
The input string in this case is permissible to contain spaces and tabs.
22 - Why is C called the Mother of all Languages?
5. Arrays, lists, functions, strings, and other fundamental concepts and data structures
were introduced in C. The C language serves as the foundation for many other languages. As a
result, it is regarded as the origin of all languages.
23 - What is the purpose of printf() and scanf() in C Program?
printf() is used to print the values on the screen. To print certain values, and on
the other hand, scanf() is used to scan the values. We need an appropriate datatype
format specifier for both printing and scanning purposes. For example,
%d: It is a datatype format specifier used to print and scan an integer value.
%s: It is a datatype format specifier used to print and scan a string.
%c: It is a datatype format specifier used to display and scan a character value.
%f: It is a datatype format specifier used to display and scan a float value.
24 - What is the main difference between the Compiler and the Interpreter?
The C language uses a compiler, which instantly converts the entire programme into
machine code. On the other hand, high-end programming languages like Java and others
require interpreters. Line by line code compilation is how it is intended to work.
25 - Explain the # pragma directive.
The Pragma Directive is explained in the following sentences.
This preprocessor directive can be used to enable or disable specific functionalities.
There are three different kinds: pragma startup, pragma exit, and pragma warn.
We can specify the functions called upon programme startup using the #pragma startup
command.
We can specify functions called upon programme exit using the #pragma exit command.
#pragma warn instructs the computer whether or not to suppress any warnings.
26 - Which structure is used to link the program and the operating system?
The following examples provide an explanation for the response:
File is the framework that connects the operating system and a programme.
The header file "stdio.h" (standard input/output header file) contains a definition for the file.
It includes details about the file now being used, including its size and placement in memory.
It has a character pointer that directs attention to the character being opened.
The operating system and the programme are informed which file is to be accessed when a file
is opened.
27 - What is the code in a while loop that returns the output of the given code ?
#include <stdio.h>
int main () {
int a;
6. /* for loop execution */
for( a = 1; a <= 100; a++ )
{
printf("%dn",a * a);
}
return 0;
}
28 - What is the explanation for modular programming?
Module programming is the process of breaking up the main programme into
executable sections. This idea encourages reusability.
29 - What are the ways to a null pointer that can be used in the C programming
language?
There are three ways to use null pointers.
as a value for errors.
as an indicator value.
to stop the recursive data structure from being indirect.
30 - What is indirection?
There is no direct reference to the value of the variable if you have defined a pointer to
it or any other memory object. The indirect reference is what it is called. However, a variable
has a direct reference to its value when it is declared.