SlideShare uma empresa Scribd logo
1 de 11
Baixar para ler offline
Interview Questions For C Language
1. What is C programming language?
Ans: C is a widely used, simple-to-learn, and flexible general-purpose programming language.
This structured programming language may be used to construct a wide range of software,
including more complex ones like the Python interpreter, the Git repository, the Oracle database,
and others, as well as operating systems like Windows.
2. What are the basic data types in C?
Ans: In C, there are four fundamental data types: double floating-point, floating-point,
characters, and integers. These data types are used in C programmes to specify variables and
functions.
1. Integer: Integers are used to represent whole numbers. Copies may or may not have a
signature. To declare integer variables, use the "int" keyword.
2. Character: Single characters, such as letters, numerals, and symbols, are represented by
characters. They are declared using the "char" keyword.
3. Floating-point: Float-point data types are used to represent actual numbers with decimal
points. Either single precision or double precision is possible. Declaring floating-point variables
requires the use of the "float" and "double" keywords.
4. Double floating-point: Double floating-point data types more accurately reflect actual numbers
when compared to floating-point data types.
For example,
int x = 10;
char c = 'A';
float f = 3.14;
double d = 3.14159;
3.What is a constant and how is it declared in C?
Ans: A constant is a value in a program that cannot be changed during its execution. In C,
constants are declared using the "const" keyword. Once a constant is defined, its value cannot
be changed throughout the program's execution. Constants can be used in place of literal
values to make code more readable and maintainable.
The syntax for declaring a constant in C is as follows: const data_type constant_name = value;
4. What are the different types of operators in C?
Ans: Operators in the C programming language are symbols that denote specific actions to be
taken on operands (variables, constants, or expressions). In C, there are several kinds of
operators, such as:
1. Arithmetic Operators: Used for addition, subtraction, multiplication, division, and modulus
operations.
Examples include plus (+), minus (-), * (multiplication), / (division), and % (modulus).
2. Relational Operators: These are used to compare two values and return either true or false
as a boolean value.
For instance,!= (not equal), == (equality), (less than), > (greater than), = (less than or equal to),
and >= (greater than or equal to)
3. Logical Operators: These are used to combine two or more relational expressions and return
a boolean (true or false) value.
Example:! (logical not), || (logical either), and && (logical and).
4. Bitwise Operators: These are used to perform bitwise operations at the bit level on two
operands.
Example: & (bitwise and), | (bitwise or), ^ (bitwise exclusive or), ~ (bitwise complement), << (left
shift), >> (right shift)
5. Assignment operators : Are employed to simultaneously assign a value to a variable and
carry out an action.
Example: = (simple assignment), += (add and assign), -= (subtract and assign), *= (multiply and
assign), /= (divide and assign), %= (modulus and assign), <<= (left shift and assign), >>= (right
shift and assign), &= (bitwise and and assign), |= (bitwise or and assign), ^= (bitwise exclusive
or and assign)
6. Use a Conditional operation dependent on the outcome of a boolean expression by using a
conditional operator.
Example: ?: (conditional operator)
7. Sizeof Operator: Used to calculate a data type or variable's size in bytes.
1. Example: sizeof(int), sizeof(char), sizeof(float)
8. Address and Pointer Operators: Used to manipulate memory addresses and pointers.
1. Example: & (address of), * (pointer to)
These operators can be used in numerous ways to produce complicated expressions that carry
out various actions in a C program.
5. What is a conditional statement in C?
Ans: In C programming, conditional statements are employed to base decisions on the
circumstances. In C, conditional statements are processed sequentially if there is no condition
around them. If a condition is added to a block of statements, the execution flow may change
depending on how the condition is evaluated. In "C", this procedure is known as
decision-making.
The following two structures in C can be used to create conditional statements:
1. If statement
2. If-else statement
6. What is a loop in C?
Ans: A loop is a programming technique that enables the repeated execution of a block of code
depending on certain circumstances. C supports "while" loops, "do-while" loops, and "for" loops
as its three different forms of loops.
● The "while" loop executes the block of code as long as a certain condition is true.
● The "do-while" loop executes the block of code at least once, and then repeatedly as
long as a certain condition is true.
● The "for" loop executes the block of code a certain number of times, based on an
initialization, condition, and update statement.
Loops are useful in situations where the same code needs to be executed multiple times with
different values. They help to reduce code duplication and improve code efficiency.
7. What is a header file in C and how is it used?
Ans : The term "header file" refers to a file with the extension ".h" that includes shared C
function declarations and macro definitions. There are two different kinds of header files: those
created by the programmer and those provided by the compiler.
For example, if you want to use the "printf" function in your C program, you would include the
"stdio.h" header file which contains the prototype for the "printf" function:
#include <stdio.h>
int main() {
printf("Hello, world!n");
return 0;
}
The "#include" directive instructs the C preprocessor to copy the contents of the "stdio.h" file
into your source file before compilation. This allows you to use the functions and declarations in
the header file without having to rewrite them in your source code.
8. What is a structure in C and how is it declared?
Ans: A user-defined data type called a structure enables you to unify variables of various data
kinds under a single name. In C, a structure is declared by using the "struct" keyword, the
structure's name, and a set of braces that enclose the variables that make up the structure.
A structure is declared in C using the following syntax:
struct structure_name {
data_type1 variable_name1;
data_type2 variable_name2;
...
data_typen variable_namen;
};
Here, "structure_name" is the name of the structure, and "variable_name1" through
"variable_namen" are the names of the variables that make up the structure. The variables can
be of any data type, including other structures.
Once a structure is declared, you can create variables of that structure type and access the
variables inside the structure using the dot (".") operator.
9. What are the different data types in C language?
Ans: The different data types in C language are int, char, float, double, and void.
1. int - used to represent integer values
2. float - used to represent floating-point values with single precision
3. double - used to represent floating-point values with double precision
4. char - used to represent a single character or an integer value that corresponds to a
character in the ASCII table.
In addition to these basic data types, C also provides the following derived data types:
1. Arrays - used to store a collection of values of the same data type
2. Pointers - used to store memory addresses of variables
3. Structures - used to group together variables of different data types under a single name
4. Unions - used to allocate memory for multiple variables of different data types but only
one variable can be accessed at a time
5. Enumerations - used to define a set of named constants.
10. What is a function in C language?
Ans: A function in C language is a block of code that performs a specific task and can be called
from anywhere in the program (e.g. int add(int x, int y) { return x + y; }).
11. What is a string in C and how is it declared?
Ans: In C, a string is a sequence of characters stored in consecutive memory locations. To
declare a string, you can use the character array data type, where each element of the array
represents a character in the string, and the last element is the null terminator '0'. Here's an
example of declaring a string in C:
Example:
char myString[] = "Hello, World!";
Here, `myString` is an array of characters that contains the string "Hello, World!". Note that the
null terminator is automatically added to the end of the string.
12. Why is C called a mid-level programming language?
Ans: C is called a mid-level programming language because it has features of both low-level
and high-level programming languages. It provides low-level access to memory through pointers
and high-level abstractions such as functions, control structures, and data types. This makes it
suitable for writing both system-level and application-level software.
13. What is the use of printf() and scanf() functions? Also explain format specifiers?
Ans: The `printf()` function is used for displaying output to the console or other output devices.
The `scanf()` function is used for reading input from the console or other input devices. Format
specifiers are special codes used in formatted input and output functions to indicate the type of
data being read or written. They are preceded by a `%` symbol in the format string.
To specify the type of data being read or written, format specifiers are codes used in C's
formatted input and output functions. They instruct the function on the expected kind of data and
the formatting to be used when it is displayed or written.
The most common format specifiers are:
● %d: for integer values
● %f: for floating-point values
● %c: for characters
● %s: for strings
● %p: for pointer values
● %o: for octal values
● %x or %X: for hexadecimal values
14. What is a Preprocessor?
Ans: The preprocessor is a component of the C compiler that processes the source code before
it is compiled.
It performs a set of operations on the code, such as macro expansion, file inclusion, and
conditional compilation.
The preprocessor is invoked by special commands called preprocessor directives, which begin
with a hash symbol (#).
The most commonly used preprocessor directives are #define, #include, and #ifdef.
The #define directive is used to create a macro, which is a symbolic name that is replaced with
a corresponding value in the code.
The #include directive is used to include a header file in the code.
The #ifdef directive is used to check if a certain macro is defined, and conditionally include or
exclude code based on its value.
15. What is a pointer in C?
Ans: A pointer in C is a variable that stores the memory address of another variable. It is
declared using the `*` symbol, and can be used to indirectly access and manipulate the values
stored in memory locations.
Here's a example of using a pointer to assign a value to a variable in C:
```
#include <stdio.h>
int main() {
int x = 5;
int *ptr;
ptr = &x;
*ptr = 10;
printf("The value of x is %dn", x);
return 0;
}
```
In this example, we declare an integer variable `x` and set its initial value to `5`. We also declare
an integer pointer `ptr`, and assign it the memory address of `x` using the `&` operator. We then
use the `*` operator to dereference `ptr` and assign the value `10` to the memory location
pointed to by `ptr`. This effectively changes the value of `x` to `10`. Finally, we use `printf()` to
print the updated value of `x`.
16. What is typecasting in C?
Ans: The process of changing a variable's datatype is known as typecasting. We must explicitly
transform the data type into another data type if we wish to save a huge type value as an int
type.
Syntax: (data_type)expression;
For Example:
int x;
for(x=97; x<=122; x++)
{
printf("%c", (char)x); /*Explicit casting from int to char*/
}
17. What is recursion in C?
Ans: Recursion occurs when a C function calls a duplicate of itself. To put it another way, this
method is known as recursion when a function calls itself. This function is also referred to as a
recursive function.
Syntax of Recursive Function:
void do_recursion()
{
... .. ...
do_recursion();
... .. ...]
}
int main()
{
... .. ...
do_recursion();
... .. ...
}
18. Why doesn’t C support function overloading?
Function overloading is not supported by C since it is unable to differentiate between functions
based on their signatures (parameter types and number of arguments). If you attempt to declare
more than one function with the same name in C, a compilation error will take place. Each
function has to be given a unique name.
For example, the following code is not allowed in C:
```
int add(int a, int b) {
return a + b;
}
float add(float a, float b) {
return a + b;
}
```
Because C++ supports function signature differentiation, which enables functions with the same
name to be distinguished based on their parameter types and/or a number of parameters,
function overloading is possible.
19. What are Enumerations?
Ans: Enumerations in C are user-defined data types used to assign names to integer constants,
making it easier to read and maintain code. An enumeration consists of a set of named integer
constants, known as enumerators or members, which are typically used to represent a finite set
of values for a given variable.
For Example:
#include <stdio.h>
enum Days {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday};
int main() {
enum Days today = Wednesday;
printf("Today is %dn", today); // Output: Today is 2
return 0;
}
In this example, we declare an enumeration called `Days` that has seven possible values -
`Monday`, `Tuesday`, `Wednesday`, `Thursday`, `Friday`, `Saturday`, and `Sunday`. We then
declare a variable called `today` of type `Days` and assign it the value `Wednesday`. We then
print out the value of `today`, which is `2` because `Wednesday` is the third value in the
enumeration (counting from `0`).
20. What is the difference between global int and static int declaration?
Ans: The main difference between a global `int` and a `static int` declared inside a function is
their scope and lifetime.
A global `int` variable is declared outside of any function and has a global scope, which means it
can be accessed by any function in the program. It also has a lifetime that lasts for the entire
duration of the program.
On the other hand, a `static int` variable declared inside a function has a local scope, which
means it can only be accessed by that function. However, it has a lifetime that lasts for the
entire duration of the program, just like a global variable. Additionally, a `static int` variable
retains its value between function calls, whereas a regular local variable would be re-initialized
each time the function is called.
In summary, a global `int` variable can be accessed by any function in the program, whereas a
`static int` variable declared inside a function is limited to that function's scope, but retains its
value between function calls.
21. What is the difference between a structure and a union in C?
In C, a structure is a user-defined composite data type that groups together related data of
different data types under a single name. A union, on the other hand, is also a user-defined
composite data type that allows storing different data types in the same memory location at
different times.
The main difference between a structure and a union is in the way they store and access data.
In a structure, each member variable has its own memory location, while in a union, all
members share the same memory location. This means that modifying one member of a union
will change the value of all other members as well. Additionally, the size of a union is determined
by the size of its largest member, while the size of a structure is the sum of the sizes of all its
members.
For examples:
1. Example of a structure in C:
```
struct person {
char name[50];
int age;
float salary;
};
int main() {
struct person p1; // Declaring a variable of type struct person
// Assigning values to the members of the structure
strcpy(p1.name, "John");
p1.age = 25;
p1.salary = 5000.0;
// Accessing the members of the structure
printf("Name: %sn", p1.name);
printf("Age: %dn", p1.age);
printf("Salary: %.2fn", p1.salary);
return 0;
}
```
2. Example of a union in C:
```
union data {
int i;
float f;
char c;
};
int main() {
union data d; // Declaring a variable of type union data
d.i = 10; // Assigning a value to the integer member
printf("i = %dn", d.i);
d.f = 3.14; // Assigning a value to the float member
printf("f = %.2fn", d.f);
d.c = 'a'; // Assigning a value to the character member
printf("c = %cn", d.c);
return 0;
}
Enquiry now
https://login360.in/
+91-63 85 87 28 10
enquiry@login360.in

Mais conteúdo relacionado

Semelhante a Interview Questions For C Language

Semelhante a Interview Questions For C Language (20)

C material
C materialC material
C material
 
venkatesh.pptx
venkatesh.pptxvenkatesh.pptx
venkatesh.pptx
 
C language
C languageC language
C language
 
C notes
C notesC notes
C notes
 
Fundamentals of c language
Fundamentals of c languageFundamentals of c language
Fundamentals of c language
 
unit2.pptx
unit2.pptxunit2.pptx
unit2.pptx
 
history of c.ppt
history of c.ppthistory of c.ppt
history of c.ppt
 
Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
 
Pc module1
Pc module1Pc module1
Pc module1
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptx
 
C intro
C introC intro
C intro
 
C LANGUAGE NOTES
C LANGUAGE NOTESC LANGUAGE NOTES
C LANGUAGE NOTES
 
The smartpath information systems c pro
The smartpath information systems c proThe smartpath information systems c pro
The smartpath information systems c pro
 
unit 1 cpds.pptx
unit 1 cpds.pptxunit 1 cpds.pptx
unit 1 cpds.pptx
 
UNIT 1 NOTES.docx
UNIT 1 NOTES.docxUNIT 1 NOTES.docx
UNIT 1 NOTES.docx
 
C programming.pdf
C programming.pdfC programming.pdf
C programming.pdf
 
CProgrammingTutorial
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
 
1. introduction to computer
1. introduction to computer1. introduction to computer
1. introduction to computer
 
Basic c
Basic cBasic c
Basic c
 
C programming language tutorial for beginers.pdf
C programming language tutorial for beginers.pdfC programming language tutorial for beginers.pdf
C programming language tutorial for beginers.pdf
 

Último

HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 

Último (20)

HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 

Interview Questions For C Language

  • 1. Interview Questions For C Language 1. What is C programming language? Ans: C is a widely used, simple-to-learn, and flexible general-purpose programming language. This structured programming language may be used to construct a wide range of software, including more complex ones like the Python interpreter, the Git repository, the Oracle database, and others, as well as operating systems like Windows. 2. What are the basic data types in C? Ans: In C, there are four fundamental data types: double floating-point, floating-point, characters, and integers. These data types are used in C programmes to specify variables and functions. 1. Integer: Integers are used to represent whole numbers. Copies may or may not have a signature. To declare integer variables, use the "int" keyword. 2. Character: Single characters, such as letters, numerals, and symbols, are represented by characters. They are declared using the "char" keyword. 3. Floating-point: Float-point data types are used to represent actual numbers with decimal points. Either single precision or double precision is possible. Declaring floating-point variables requires the use of the "float" and "double" keywords. 4. Double floating-point: Double floating-point data types more accurately reflect actual numbers when compared to floating-point data types. For example, int x = 10; char c = 'A'; float f = 3.14; double d = 3.14159; 3.What is a constant and how is it declared in C? Ans: A constant is a value in a program that cannot be changed during its execution. In C, constants are declared using the "const" keyword. Once a constant is defined, its value cannot be changed throughout the program's execution. Constants can be used in place of literal values to make code more readable and maintainable.
  • 2. The syntax for declaring a constant in C is as follows: const data_type constant_name = value; 4. What are the different types of operators in C? Ans: Operators in the C programming language are symbols that denote specific actions to be taken on operands (variables, constants, or expressions). In C, there are several kinds of operators, such as: 1. Arithmetic Operators: Used for addition, subtraction, multiplication, division, and modulus operations. Examples include plus (+), minus (-), * (multiplication), / (division), and % (modulus). 2. Relational Operators: These are used to compare two values and return either true or false as a boolean value. For instance,!= (not equal), == (equality), (less than), > (greater than), = (less than or equal to), and >= (greater than or equal to) 3. Logical Operators: These are used to combine two or more relational expressions and return a boolean (true or false) value. Example:! (logical not), || (logical either), and && (logical and). 4. Bitwise Operators: These are used to perform bitwise operations at the bit level on two operands. Example: & (bitwise and), | (bitwise or), ^ (bitwise exclusive or), ~ (bitwise complement), << (left shift), >> (right shift) 5. Assignment operators : Are employed to simultaneously assign a value to a variable and carry out an action. Example: = (simple assignment), += (add and assign), -= (subtract and assign), *= (multiply and assign), /= (divide and assign), %= (modulus and assign), <<= (left shift and assign), >>= (right shift and assign), &= (bitwise and and assign), |= (bitwise or and assign), ^= (bitwise exclusive or and assign) 6. Use a Conditional operation dependent on the outcome of a boolean expression by using a conditional operator. Example: ?: (conditional operator) 7. Sizeof Operator: Used to calculate a data type or variable's size in bytes. 1. Example: sizeof(int), sizeof(char), sizeof(float) 8. Address and Pointer Operators: Used to manipulate memory addresses and pointers. 1. Example: & (address of), * (pointer to) These operators can be used in numerous ways to produce complicated expressions that carry out various actions in a C program.
  • 3. 5. What is a conditional statement in C? Ans: In C programming, conditional statements are employed to base decisions on the circumstances. In C, conditional statements are processed sequentially if there is no condition around them. If a condition is added to a block of statements, the execution flow may change depending on how the condition is evaluated. In "C", this procedure is known as decision-making. The following two structures in C can be used to create conditional statements: 1. If statement 2. If-else statement 6. What is a loop in C? Ans: A loop is a programming technique that enables the repeated execution of a block of code depending on certain circumstances. C supports "while" loops, "do-while" loops, and "for" loops as its three different forms of loops. ● The "while" loop executes the block of code as long as a certain condition is true. ● The "do-while" loop executes the block of code at least once, and then repeatedly as long as a certain condition is true. ● The "for" loop executes the block of code a certain number of times, based on an initialization, condition, and update statement. Loops are useful in situations where the same code needs to be executed multiple times with different values. They help to reduce code duplication and improve code efficiency. 7. What is a header file in C and how is it used? Ans : The term "header file" refers to a file with the extension ".h" that includes shared C function declarations and macro definitions. There are two different kinds of header files: those created by the programmer and those provided by the compiler. For example, if you want to use the "printf" function in your C program, you would include the "stdio.h" header file which contains the prototype for the "printf" function: #include <stdio.h> int main() { printf("Hello, world!n"); return 0; }
  • 4. The "#include" directive instructs the C preprocessor to copy the contents of the "stdio.h" file into your source file before compilation. This allows you to use the functions and declarations in the header file without having to rewrite them in your source code. 8. What is a structure in C and how is it declared? Ans: A user-defined data type called a structure enables you to unify variables of various data kinds under a single name. In C, a structure is declared by using the "struct" keyword, the structure's name, and a set of braces that enclose the variables that make up the structure. A structure is declared in C using the following syntax: struct structure_name { data_type1 variable_name1; data_type2 variable_name2; ... data_typen variable_namen; }; Here, "structure_name" is the name of the structure, and "variable_name1" through "variable_namen" are the names of the variables that make up the structure. The variables can be of any data type, including other structures. Once a structure is declared, you can create variables of that structure type and access the variables inside the structure using the dot (".") operator. 9. What are the different data types in C language? Ans: The different data types in C language are int, char, float, double, and void. 1. int - used to represent integer values 2. float - used to represent floating-point values with single precision 3. double - used to represent floating-point values with double precision 4. char - used to represent a single character or an integer value that corresponds to a character in the ASCII table. In addition to these basic data types, C also provides the following derived data types: 1. Arrays - used to store a collection of values of the same data type 2. Pointers - used to store memory addresses of variables 3. Structures - used to group together variables of different data types under a single name 4. Unions - used to allocate memory for multiple variables of different data types but only one variable can be accessed at a time 5. Enumerations - used to define a set of named constants.
  • 5. 10. What is a function in C language? Ans: A function in C language is a block of code that performs a specific task and can be called from anywhere in the program (e.g. int add(int x, int y) { return x + y; }). 11. What is a string in C and how is it declared? Ans: In C, a string is a sequence of characters stored in consecutive memory locations. To declare a string, you can use the character array data type, where each element of the array represents a character in the string, and the last element is the null terminator '0'. Here's an example of declaring a string in C: Example: char myString[] = "Hello, World!"; Here, `myString` is an array of characters that contains the string "Hello, World!". Note that the null terminator is automatically added to the end of the string. 12. Why is C called a mid-level programming language? Ans: C is called a mid-level programming language because it has features of both low-level and high-level programming languages. It provides low-level access to memory through pointers and high-level abstractions such as functions, control structures, and data types. This makes it suitable for writing both system-level and application-level software. 13. What is the use of printf() and scanf() functions? Also explain format specifiers? Ans: The `printf()` function is used for displaying output to the console or other output devices. The `scanf()` function is used for reading input from the console or other input devices. Format specifiers are special codes used in formatted input and output functions to indicate the type of data being read or written. They are preceded by a `%` symbol in the format string. To specify the type of data being read or written, format specifiers are codes used in C's formatted input and output functions. They instruct the function on the expected kind of data and the formatting to be used when it is displayed or written. The most common format specifiers are: ● %d: for integer values ● %f: for floating-point values
  • 6. ● %c: for characters ● %s: for strings ● %p: for pointer values ● %o: for octal values ● %x or %X: for hexadecimal values 14. What is a Preprocessor? Ans: The preprocessor is a component of the C compiler that processes the source code before it is compiled. It performs a set of operations on the code, such as macro expansion, file inclusion, and conditional compilation. The preprocessor is invoked by special commands called preprocessor directives, which begin with a hash symbol (#). The most commonly used preprocessor directives are #define, #include, and #ifdef. The #define directive is used to create a macro, which is a symbolic name that is replaced with a corresponding value in the code. The #include directive is used to include a header file in the code. The #ifdef directive is used to check if a certain macro is defined, and conditionally include or exclude code based on its value. 15. What is a pointer in C? Ans: A pointer in C is a variable that stores the memory address of another variable. It is declared using the `*` symbol, and can be used to indirectly access and manipulate the values stored in memory locations. Here's a example of using a pointer to assign a value to a variable in C: ``` #include <stdio.h> int main() { int x = 5; int *ptr; ptr = &x; *ptr = 10; printf("The value of x is %dn", x); return 0; } ``` In this example, we declare an integer variable `x` and set its initial value to `5`. We also declare an integer pointer `ptr`, and assign it the memory address of `x` using the `&` operator. We then
  • 7. use the `*` operator to dereference `ptr` and assign the value `10` to the memory location pointed to by `ptr`. This effectively changes the value of `x` to `10`. Finally, we use `printf()` to print the updated value of `x`. 16. What is typecasting in C? Ans: The process of changing a variable's datatype is known as typecasting. We must explicitly transform the data type into another data type if we wish to save a huge type value as an int type. Syntax: (data_type)expression; For Example: int x; for(x=97; x<=122; x++) { printf("%c", (char)x); /*Explicit casting from int to char*/ } 17. What is recursion in C? Ans: Recursion occurs when a C function calls a duplicate of itself. To put it another way, this method is known as recursion when a function calls itself. This function is also referred to as a recursive function. Syntax of Recursive Function: void do_recursion() { ... .. ... do_recursion(); ... .. ...] } int main() { ... .. ... do_recursion(); ... .. ... } 18. Why doesn’t C support function overloading? Function overloading is not supported by C since it is unable to differentiate between functions based on their signatures (parameter types and number of arguments). If you attempt to declare
  • 8. more than one function with the same name in C, a compilation error will take place. Each function has to be given a unique name. For example, the following code is not allowed in C: ``` int add(int a, int b) { return a + b; } float add(float a, float b) { return a + b; } ``` Because C++ supports function signature differentiation, which enables functions with the same name to be distinguished based on their parameter types and/or a number of parameters, function overloading is possible. 19. What are Enumerations? Ans: Enumerations in C are user-defined data types used to assign names to integer constants, making it easier to read and maintain code. An enumeration consists of a set of named integer constants, known as enumerators or members, which are typically used to represent a finite set of values for a given variable. For Example: #include <stdio.h> enum Days {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday}; int main() { enum Days today = Wednesday; printf("Today is %dn", today); // Output: Today is 2 return 0; } In this example, we declare an enumeration called `Days` that has seven possible values - `Monday`, `Tuesday`, `Wednesday`, `Thursday`, `Friday`, `Saturday`, and `Sunday`. We then declare a variable called `today` of type `Days` and assign it the value `Wednesday`. We then
  • 9. print out the value of `today`, which is `2` because `Wednesday` is the third value in the enumeration (counting from `0`). 20. What is the difference between global int and static int declaration? Ans: The main difference between a global `int` and a `static int` declared inside a function is their scope and lifetime. A global `int` variable is declared outside of any function and has a global scope, which means it can be accessed by any function in the program. It also has a lifetime that lasts for the entire duration of the program. On the other hand, a `static int` variable declared inside a function has a local scope, which means it can only be accessed by that function. However, it has a lifetime that lasts for the entire duration of the program, just like a global variable. Additionally, a `static int` variable retains its value between function calls, whereas a regular local variable would be re-initialized each time the function is called. In summary, a global `int` variable can be accessed by any function in the program, whereas a `static int` variable declared inside a function is limited to that function's scope, but retains its value between function calls. 21. What is the difference between a structure and a union in C? In C, a structure is a user-defined composite data type that groups together related data of different data types under a single name. A union, on the other hand, is also a user-defined composite data type that allows storing different data types in the same memory location at different times. The main difference between a structure and a union is in the way they store and access data. In a structure, each member variable has its own memory location, while in a union, all members share the same memory location. This means that modifying one member of a union will change the value of all other members as well. Additionally, the size of a union is determined by the size of its largest member, while the size of a structure is the sum of the sizes of all its members. For examples: 1. Example of a structure in C: ``` struct person { char name[50];
  • 10. int age; float salary; }; int main() { struct person p1; // Declaring a variable of type struct person // Assigning values to the members of the structure strcpy(p1.name, "John"); p1.age = 25; p1.salary = 5000.0; // Accessing the members of the structure printf("Name: %sn", p1.name); printf("Age: %dn", p1.age); printf("Salary: %.2fn", p1.salary); return 0; } ``` 2. Example of a union in C: ``` union data { int i; float f; char c; }; int main() { union data d; // Declaring a variable of type union data d.i = 10; // Assigning a value to the integer member printf("i = %dn", d.i); d.f = 3.14; // Assigning a value to the float member printf("f = %.2fn", d.f); d.c = 'a'; // Assigning a value to the character member printf("c = %cn", d.c); return 0; }
  • 11. Enquiry now https://login360.in/ +91-63 85 87 28 10 enquiry@login360.in