Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common interview questions in C language?

2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what are the common interview questions in C language". The content of the explanation in this article is simple and clear, and it is easy to learn and understand. let's study and learn "what are the common interview questions in C language"?

Question 1: what are the core features of the c language?

It is highly portable.

The modularization ability is very strong.

Very flexible.

The loading speed and execution speed are very good.

It is very scalable.

Question 2: what are the basic data types in C language?

Int integer.

Float floating point type.

Double double floating point type.

Char single character.

Void is a special type that does not contain any values.

Question 3: explain the semantic error.

There will be a lot of semantic errors when writing a program, for example, misspelling of commands, miscounting of parameters of a function, mismatch of data types, and so on.

Question 4: how to use addition and subtraction statements in C language?

There are two ways:

+,-

Or

The traditional addition and subtraction.

Question 5: what is a reserved word for a programming language?

Reserved words refer to some keywords used in the language library. These keywords cannot be used to do other things, such as defining a variable or function, etc.

Question 6: explain dangling pointer.

First of all, we say that there is a pointer to the memory address of a variable. This variable is removed from the memory address after a period of time.

Such a pointer is called dangling pointer.

Question 7: describe the use of static functions.

Functions defined with the static static keyword are called static functions.

Such a function needs to be called in the same code.

Question 8: what is the difference between abs and fabs?

Both functions are used to take absolute values. The former is for integers. The latter is for floating-point types. The former is located in the standard library stdlib.h. The latter is in math.h.

Question 9: talk about wild pointers.

Uninitialized pointers are called wild pointers. These pointers point to a random memory address. Accessing them can lead to bad program behavior or even crash.

Question 10: what is the difference between + + an and averse +?

To add a means to add first and then take a value.

A plus means to take a value first and then increase it.

Question 11: what is the difference between an odd sign and a double sign?

The single equal sign represents the assignment operator.

The double equal sign is equal to the conditional judgment operator.

Question 12: explain the prototype function of c language.

A prototype function is a declaration of a function.

It contains the function name, the return value and a list of parameter types.

Int sum (int,int)

Question 13: explain the cyclic nature of the data type.

In the c language, when a programmer assigns a value to a variable of a data type, it may overflow. This overflow does not produce compilation errors. The final result of the assignment depends on the rest of the data type overflow.

This kind of behavior is called cyclic nature. Char, int, and long int data types have this feature. Further float, double, and long double data types do not have this feature.

Question 14: talk about the header files and uses of the c language.

The header file stores the definition of the prototype function. This file is also called a library file.

For example, printf and scanf are stored in stdio.h.

Question 15: explain the practice of commenting code during debugging.

This practice is called commenting out. Determine or eliminate errors caused by some code by blocking it.

Question 16: talk about the types of loops in the c language.

There are four types of loops in C language.

While

For

Do while

Nested loop

Question 17: what is nested loop?

One loop is contained in another loop called nested loop. The first cycle becomes an external cycle. The inner loop is called the inner loop. The number of times the inner loop is executed as the number of times of the total loop.

Question 18: what is the usual format of functions in the c language?

C language functions, including four parts.

Return value, function name, parameter, function body.

Question 19: what is the pointer of a pointer?

The pointer of a pointer is a pointer to the address where the pointer is located.

Int axi5, * xylene rooma, * * yawpex

Question 20: where is the Break keyword used?

Break can be used in loops and switch statements. Is used to terminate the current loop or to jump out of the switch.

Question 21: what is the difference between double quotes and angle brackets when using header files?

When using double quotes, first look for the header file in the current working directory, or in the built-in include path if you can't find it.

When using angle brackets, only this header file is found in the current working directory.

Question 22: what is an sequential access file?

This kind of file is used to store data and follow a sequential pattern when writing data. When reading, it is also read out according to this mode.

Question 23: how to store data in a stack data structure?

Such data are first in and then out. Only the data at the top is accessible. Push is used when storing and pop is used when getting.

Question 24: what is the meaning of C program algorithm?

The significance of the algorithm is to improve the execution efficiency of the program, whether to pay attention to the saving of space or time, is the factor to be considered when writing the algorithm.

Question 25: what is the role of the volatile keyword?

The keyword specified by volatile may be changed by the system, hardware, process / thread, forcing the compiler to get the value of the variable from memory each time, rather than reading it from the optimized register.

Question 26: which of the following conditional operators is not available in C language?

=, =

The answer is.

Question 27: is it possible to include a line of code in curly braces in c language?

Yes, of course. Many programmers use curly braces to regulate code structure, whether on one line or multiple lines.

Question 28: describe modifier.

Modifier is the prefix of the data type and is used to identify the size of storage space.

For example, in a 32-bit processor system, the length of the shaping is 4bits.

If we add the following modifier:

Long Int can save 8 bits.

Short Int accounted for 2 bits.

Question 29: what modifiers are there in c language?

Short

Long

Signed

Unsigned

Long long

Question 30: how to generate random numbers in c language?

The rand function is used to generate random numbers, which can produce any integer starting at 0.

Question 31: can you store the number 32768 in the integer?

The integer type can hold any value from-32768 to 32767. But 32768 is not in this range. Modifier is what we need at this time. The Long Int data type can hold this number.

Question 32: can I customize the header file in C language?

Yes, of course. After defining the header file, you can store the prototype of the function.

When using it, use include to include the name of the file.

Question 33: explain the dynamic data structure in c language.

Dynamic data structures are very efficient in accessing memory. Access to memory depends on the needs of the program.

Question 34: what is indirection?

If you set a pointer variable, it points to a value variable or a memory object. In this case, there is no direct reference to the value variable and object. This situation is called indirection.

But if we declare a variable, it is a direct reference to the value.

Question 35: when will a null pointer be used in the c language?

There are three cases in which null pointers are used in the c language.

As a wrong value.

As a monitoring value.

Terminates indirection in a recursive data structure.

Question 36: explain modular programming.

Dividing the main program into several small, executable modules is called modular programming. This concept is to enhance reusability. At the same time, the maintainability of the program is improved.

Question 37: what's the difference between Call by value and call by reference?

Call by value passes a value. Call by reference sent the address.

Question 38: how to define a string variable in c language

Use char to define an array of characters.

Question 39: when to use void when defining a function?

You can use void when the function does not return a value.

Question 40: what is preprocessor directives?

Preprocessor directives is usually placed at the beginning of the program. It is mainly used to specify the calling library file. Another use is to define constant variables, macro definitions, and so on. # at the beginning.

Question 41: is this assignment right? What's wrong?

MyName= "test"

Wrong.

We cannot assign a string with an equal sign. You need to use strcpy.

Question 42: why is c considered an intermediate language?

This is because c language can not only write programs like high-level languages, but also directly manipulate hardware like low-level languages such as assembly.

Question 43: what is a linked list?

A linked list is a data structure formed by a series of elements joined together. In C language, linked lists are built with pointers. Using linked list data structures is a way to compare operations in memory.

Question 44: what is fifo?

First in first out. Queues are typical first in first out, data structures.

Question 45: what is a binary tree?

A binary tree is an extension of a linked list. Each node has two pointers, one to the left and one to the right.

Question 46: some of the C language is reserved in uppercase, right?

No, all reserved words in c must be lowercase, otherwise the compiler of c will report an error.

Question 47: what is output redirection?

Output redirection refers to the output of the program, in addition to the output on the screen, for example, to a file.

Question 48: what are global variables and how are they defined?

Global variables are variables that can be accessed anywhere in the program. It is generally defined after preprocessor directives.

Question 49: getch and getche, what is the difference between these two functions?

The former is to assign the user's input to a variable.

The latter prints the user's input to the screen and assigns it to a variable.

Question 50: what is the difference between text files and binary files?

Text files store content that can be read by human beings. It contains alphanumeric and other characters.

The binaries store 1s and zeros, which only a computer can read.

Question 51: how to search for data in a data file by random access?

Fseek

Provide three parameters to this function after the file is opened. One is the pointer to the file, one is the number of bytes to search, and the other is the starting point of the search in the file.

Question 52: is there a built-in sorting function in the c language?

Qsort

Question 53: what are the advantages and disadvantages of heap?

Storing data on heap is slower than storing data on stack.

But the main advantage of using heap is flexibility. This is because memory access, allocation, and deletion can be performed in any order.

The slow speed of heap can be avoided through good algorithm and design.

Question 54: how to turn a string into a number?

Atoi

Atof

This can be done using the built-in functions in the c language. You can also write your own functions.

Thank you for your reading. the above is the content of "what are the common interview questions in C language?" after the study of this article, I believe you have a deeper understanding of the common interview questions in C language. the specific use of the situation also needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report