Tuesday, October 7, 2025

C Interview Questions & Answers || Freshers Level || Set - III

 Question: 1. Why is the C language called “the origin/mother of all other languages”?

Answer: C is called the origin or mother of all other languages because it is the oldest language that came into existence and created the base of the programming world. Many modern programming languages, such as C++, Java, and Python, have evolved from C. C also has wide applications, as it is widely used to design compilers and kernels.

Question: 2. The why main( ) function is used in C?

Answer: The main() function is the entry section of every program and is the main part from where the execution of the program starts. It is very important to include the main() function in every C program; otherwise, program execution will not take place. It is not executed like a common function meant for some specific purpose.

Question: 3. Explain the difference between variable and constant in C

Answer: Both variables and constants are used for constructing or designing a program in C. The key difference is that the values of variables assigned can be altered or changed at any time in the program as per requirements. In contrast, the value of constants cannot be altered and remains the same as declared throughout the program.

Question: 4. What do you mean by Pre-processor?

Answer: The Pre-processor is considered a separate step in the compilation process. Before compilation, the written code is first translated using a pre-processor. It acts as a directive that gives instructions to the compiler.

Question: 5. Explain the use of the header file in C

Answer: The header file is a most important thing to include while writing a program in C. It contains a lot of pre-defined functions that are to be used in the program. For instance, functions like printf() and scanf() can be used under the <stdio.h> header file.

Question: 6. What are reserved keywords in C?

Answer: Reserved keywords have a special meaning in C and are reserved for something special, meaning they can only be used for that specific purpose. There is a total of 32 reserved keywords available in C.

Question: 7. What is the difference between a variable that is declared as local or global?

Answer: Global variables are declared globally (i.e., outside the function) and can be used anywhere inside the program at any time. Local variables are declared inside a particular function; they begin execution when that function starts and lose execution when the function terminates.

Question: 8. Why the “\0” character is used?

Answer: The “\0” character is called a NULL character and is used for indicating the end of the strings.

Question: 9. Explain the difference between the “equal to =” and “double equal to ==” operator

Answer: The “=” (equal to) operator is the assignment operator, which is used for assigning any value. The “==” (double equal to) operator is the equivalent operator, which is used for comparing whether two values are equal or not.

Question: 10. What do you understand by nested loop?

Answer: The loop inside another loop is called a nested loop. It is mainly used when working with multi-dimensional concepts.

Question: 11. What is the use of curly braces { } in the program?

Answer: Curly braces are mainly used to tell the scope of a particular function, meaning they are used for grouping the lines of code in one function. It is considered good practice to use curly braces as it makes the code look good.

Question: 12. Explain Syntax error

Answer: A syntax error is an error found in the source code of the program. Since C is a case-sensitive language, all syntax should be written carefully. A syntax error may be any command that was misspelt or written in the wrong way.

Question: 13. What do you understand by the “void” keyword when used in any function?

Answer: When declaring any function, the return type must be mentioned. If that function is not returning any value (e.g., it is simply used for displaying some output), then void is used as the return type. If the function is returning a value, then void cannot be used.

Question: 14. Explain the term debugging

Answer: Debugging simply means to find errors. When an error is encountered, the compiler stops compiling the code. It then becomes the programmer’s duty to find that error in the code, which is achieved by debugging.

Question: 15. What are NULL pointers in C?

Answer: If the exact position to be assigned is unknown at the time of pointer declaration, the pointer is simply pointed to a NULL value, which is 0. This pointer is then called a NULL pointer.

Question: 16. Explain the term Memory leak in C

Answer: A memory leak occurs when memory is created in the Heap data structure and the programmer forgets to delete that memory after use. This causes the efficiency of the program to slow down.

Question: 17. What do you mean by dangling pointers in C?

Answer: A dangling pointer is a pointer that points to a memory location which has already been deleted. Alternatively, it can be defined as a pointer that points to the dereferenced memory location.

Question: 18. What do you mean by auto keyword in C?

Answer: A local variable is also simply called an auto variable. It is optional to use the auto keyword before the declaration of the local variable.

Question: 19. What is a token in C?

Answer: A token is simply called an identifier. It is classified as the smallest unit of the program. A token can be anything like a constant, keyword, or strings.

Question: 20. What do you understand by infinite loop?

Answer: An infinite loop is when the loop body is executed continuously without taking a break. This can be achieved by constructs such as for (; ;) or while (1).

Question: 21. Tell the different storage class specifiers available in C

Answer: The different storage class specifiers available in C are register, auto, extern, and static.

Question: 22. Explain the role of the structure types in C Programming

Answer: A structure is used to store values of different data types under one name. It allows for easy access and is mainly used to maintain records.

Question: 23. Describe in brief the file opening mode “w+”

Answer: The “w+” mode signifies that the file is opened for both reading and writing purposes. If the specified file does not exist, this mode will create the file. If the file does exist, the content will be overridden.

Question: 24. For what purpose a double hash “##” operators used in C

Answer: The double hash “##” operator is primarily used to concatenate 2 tokens into one. It is also referred to as a preprocessor macro in C.

Question: 25. Explain the use of “#define” in C

Answer: #define is a pre-processor directive. It is mainly used to define a constant value in our program.

…till next post, bye-bye & take care.

Monday, October 6, 2025

C Interview Questions & Answers || Experienced Level || Set - II

Question: What is the program to print the factorial of a number using recursion?

Answer: The C program to find the factorial of a given number using recursion is as follows:

// C program to find factorial // of a given number

#include <stdio.h> // Function to find factorial of // a given number

unsigned int factorial(unsigned int n)

{

    if (n == 0)

        return 1;

    return n * factorial(n - 1);

}

// Driver code

int main()

{

    int num = 5;

    printf("Factorial of %d is %d", num, factorial(num));

    return 0;

}

// Output: Factorial of 5 is 120


Question: What is the use of an extern storage specifier?

Answer: The extern storage specifier, which is short for external, is used to increase the visibility of C functions and variables. It is used by one file to access variables from another file.

Question: Write a program to check an Armstrong number.

Answer: The C program to determine whether the given number is an Armstrong number or not is as follows:

// C program to determine whether // the given number is Armstrong // or not

#include <stdio.h> // Driver code

int main()

{

    int n;

    printf("Enter Number \n");

    scanf("%d", &n);

    int var = n;

    int sum = 0;

    // Loop to calculate the order of // the given number

    while (n > 0)

    {

        int rem = n % 10;

        sum = (sum) + (rem * rem * rem);

        n = n / 10;

    }

    // If the order of the number will be // equal to the number then it is // Armstrong number.

    if (var == sum)

    {

        printf("%d is an Armstrong number \n", var);

    }

    else

    {

        printf("%d is not an Armstrong number", var);

    }

    return 0;

}

// Output example: Enter Number 0 is an Armstrong number


Question: Write a program to reverse a given number.

Answer: The C program to reverse digits of a number is as follows:

// C program to reverse digits // of a number

#include <stdio.h> // Driver code

int main()

{

    int n, rev = 0;

    printf("Enter Number to be reversed : ");

    scanf("%d", &n);

    // r will store the remainder while we // reverse the digit and store it in rev

    int r = 0;

    while (n != 0)

    {

        r = n % 10;

        rev = rev * 10 + r;

        n /= 10;

    }

    printf("Number After reversing digits is: %d", rev);

    return 0;

}

// Output example: Enter Number to be reversed : 123 Number After reversing digits is: 321


…till next post, bye-bye & take care.

Sunday, October 5, 2025

DIP Switch DPST || TinkerCAD Circuits Input Component

  A single or multiple switches in a DIP (Dual In-line Package).

A single DIP switch is DPST (Double Pole Single Throw).

A DIP switch SPST x 4 contains 4 individual switches (Single Pole Single Throw).

A DIP Switch SPST x 6 contains 6 individual switches (Single Pole Single Throw). 

In other words, a single DIP switch.

Description:

This device is a toggle switch with two positions.

DIP Switch DPST || TinkerCAD Circuits Input Component

How It Works:

A DIP switch contains metal contacts that contact each together when the slider is moved, allowing electrical current to flow. This DIP switch functions as two separate toggle switches with the same lever.

Connect It:

This device has four wire leads. 1A and 1B form the first toggle switch, and 2A and 2B form the second. These switches should be wired in series with the device they are meant to control.

How It Is Used:

Click the device during simulation to change the switch position.

How It Is Used: DIP Switch DPST

Get Started:

Drag the starter circuit below into your design for a working example of how to use this part.

Get Started: DIP Switch DPST

More About DIP Switch DPST

To add a DIP Switch DPST in Tinkercad, search for "DIP Switch DPST" in the component library, drag it onto your breadboard, and connect its terminals with wires to other components in your circuit. You can then click on the DIP Switch DPST to set its name for easy identification. 

The Double Pole, Single Throw (DPST) DIP Switch is a specialized configuration of the standard Dual In-line Package switch, composed of a single actuator that simultaneously controls two separate circuits (double pole), which can only be in a simple ON or OFF state (single throw). This means it has four terminals: two inputs and two outputs. DPST DIP switches can be found across various common actuator types, including Slide, Rocker, and Piano styles, and are typically mounted to a PCB using Through-Hole or Surface Mount Technology (SMT). Key specifications for these low-power components are measured in:

  • Current Rating: Typically low, in the range of 10 mA to 200 mA at the switching voltage.

  • Voltage Rating: Often 24 VDC to 50 VDC for the maximum non-switching voltage, with a lower voltage rating for the actual switching operation.

  • Operating Temperature Range: Commonly spans from around −40∘C to +85∘C or higher.

  • Electrical Life: Measured in the number of cycles, usually 2,000 cycles minimum per switch. The DPST configuration is useful for applications requiring simultaneous control of two lines, such as switching both the live and neutral conductors in a low-voltage AC circuit or controlling two independent signal paths with a single action.

GlobalSpec – DIP Switches Selection Guide 

Website Title: GlobalSpec
Website Page URL: https://www.globalspec.com/learnmore/electrical_electronic_components/switches/dip_switches
URL recommended for (Reason): An excellent technical guide for selecting DIP switches that clearly defines Double Pole, Single Throw (DPST) in the context of switch configuration, which is essential for understanding the component.


ElProCus – DPST Switch: Circuit, Working, Specifications & Its Applications 

Website Title: ElProCus
Website Page URL: https://www.elprocus.com/dpst-switch/

URL recommended for (Reason): Provides a thorough, dedicated explanation of the DPST switch working principle, including its circuit diagram, applications (like switching mains supply), and advantages.


All About Circuits – DIP Switches: Understanding the Basics 

Website Title: All About Circuits
Website Page URL: https://www.allaboutcircuits.com/industry-articles/dip-switches-understanding-the-basics/

URL recommended for (Reason): A fundamental article that clearly explains the concept of Poles and Throws (SPST, SPDT, DPST, DPDT), which is the necessary theoretical background for anyone studying the DPST configuration.


CTS Corporation – DIP Switches Website Title: CTS Corporation
Website Page URL: https://www.ctscorp.com/Products/Switches/DIP-Switches

URL recommended for (Reason): A manufacturer's resource that explicitly lists DPST as one of the available Circuit Switching Options for their DIP switches, confirming its availability and common industrial use.


Note: Autodesk® and TinkerCAD® are trademarks of their respective company

TinkerCAD Circuits Platform related Interesting Links:

TinkerCAD Circuits Reference Handbook eBook: About Page 

Quickly Master Electronics with the TinkerCAD Circuits Reference Handbook 


…till next post, bye-bye & take care.