Found 1401 Articles for C

Explain the custom header files in C language

Bhanu Priya
Updated on 08-Mar-2021 07:20:41

480 Views

ProblemCan the user create his/her own custom header files in the C language? If yes, how can we access the user-defined header files?SolutionYes, the user can create his/her own custom header files in C.It helps you to manage the user-defined methods, global variables, and structures in a separate file, which can be used in different modules.Let’s see an example of how to create and access custom header files −ExampleGiven below is the C program to call an external function named swap in the main.c file.#include #include"swaping.h" //included custom header file void main(){    int a=40;    int b=60;    swaping ... Read More

What are Backslash character constants in C language?

Bhanu Priya
Updated on 08-Mar-2021 07:06:32

4K+ Views

A backslash ( \ ) that allows a visual representation of some nongraphic characters introduces an escape.One of the common escape constants is the newline character ( ).Backslash CharactersThe backslash characters are as follows −CharacterMeaning‘\a’alert‘\b’backspace‘\f’form feed‘’newline‘\t’horizontal tab‘\r’carriage return‘\v’vertical tab‘\’backslash‘\’ ’single quote‘\" ’double quote‘\?’Question markExample programFollowing is the C program for the backslash character constants −Example Live Demo#include #define PI 3.14 float area; void main(){    double r;    r=1.0;    area = PI * r * r;    printf("Area is %d ", area); // /n is used to enter the next statement in newline }OutputArea is 1492442840Read More

What is a command line argument in C language?

Bhanu Priya
Updated on 08-Mar-2021 07:05:15

156 Views

An executable instruction that performs a task for OS is called a command. These commands are issued from the prompt of OS.The arguments that are associated with the commands are as follows −argc - argument count.argv - argument vector.argc − It holds the total number of arguments passed from the command prompt.argv − It is a pointer to an array of character strings contains names of arguments.For example, c: |> sample. Exe hello how are you    argumentsHere, argc = 5argv[0] = sample.exeargv[1] = helloargv [2] = howargv[3] = areargv[4] = youExampleFollowing is the C program for command line argument ... Read More

Conversion of Hex decimal to integer value using C language

Bhanu Priya
Updated on 08-Mar-2021 07:03:39

6K+ Views

ProblemHow to convert the hexadecimal value to integer value by using the C programming language?Explain the concept.SolutionHexadecimal values represent in 16 symbols 1 to 9 & A to F. Here, A to F decimal equivalent is 10 to 15.ExampleFollowing is the C program for converting hexadecimal to an integer by using functions −#include #include #include int hextodc(char *hex){    int y = 0;    int dec = 0;    int x, i;    for(i = strlen(hex) - 1 ; i >= 0 ; --i)//{       if(hex[i]>='0'&&hex[i]

What do you mean by pointer to a constant in C language?

Bhanu Priya
Updated on 08-Mar-2021 07:00:06

571 Views

The value of the pointer address is constant that means we cannot change the value of the address that is pointed by the pointer.A constant pointer is declared as follows −Data_Type const* Pointer_Name;For example, int const *p// pointer to const integerExampleFollowing is the C program to illustrate a pointer to a constant −#include int main(void){    int var1 = 100;    // pointer to constant integer    const int* ptr = &var1;    //try to modify the value of pointed address    *ptr = 10;    printf("%d", *ptr);    return 0; }OutputWhen the above program is executed, it produces the ... Read More

Explain the concept of pointer to pointer and void pointer in C language?

Bhanu Priya
Updated on 08-Mar-2021 06:40:29

1K+ Views

Double pointer or pointer to pointer is a variable that holds the address of another pointer.Following is the declaration for a pointer to a pointer −datatype ** pointer_name;For example, int **p; p is a pointer to pointerInitialization − ‘&’ is used for initialization.For example, int a = 10; int *p; int **q; p = &a;Accessing − Indirection operator (*) is used for accessing.ExampleFollowing is the C program for the pointer to pointer − Live Demo#include main ( ){    int A = 10;    int *p;    int **q;    p = &A;    q = &p;    printf("A =%d", A); ... Read More

What is an inline function in C language?

Bhanu Priya
Updated on 08-Mar-2021 06:30:25

12K+ Views

The inline function can be substituted at the place where the function call is happening. Function substitution is always compiler choice.In an inline function, a function call is replaced by the actual program code.Most of the Inline functions are used for small computations. They are not suitable for large computing.An inline function is similar to a normal function. The only difference is that we place a keyword inline before the function name.Inline functions are created with the following syntax −inline function_name (){    //function definition }ExampleFollowing is the C program for inline functions −#include inline int mul(int a, int b) ... Read More

What are the Pre-processor Commands in C language?

Bhanu Priya
Updated on 08-Mar-2021 06:14:36

3K+ Views

The preprocessor is a program that sends the source code before it passes through the compiler. It operates under preprocessor directives which begin with the symbol #.TypesThe three types of preprocessor commands are as follows −Macro substitution directives.File inclusion directives.Compiler control directives.Macro substitution directivesIt replaces every occurrence of an identifier by a predefined string.The syntax for defining a macro substitution directive is as follows −# define identifier stringFor example, #define    PI    3.1415 #define    f(x)  x *x #undef     PIExampleFollowing is the C program for the macro substitution directive −#define wait getch( ) main ( ){   ... Read More

Explain the constant type qualifier in C language

Bhanu Priya
Updated on 08-Mar-2021 06:10:16

156 Views

Type qualifiers add special attributes to existing datatypes in C programming language.There are three type qualifiers in C language and constant type qualifier is explained below −ConstThere are three types of constants, which are as follows −Literal constantsDefined constantsMemory constantsLiteral constants − These are the unnamed constants that are used to specify data.For example, a=b+7 //Here ‘7’ is literal constant.Defined constants − These constants use the preprocessor command ‘define" with #For example, #define PI 3.1415Memory constants − These constants use ‘C’ qualifier ‘const’, which indicates that the data cannot be changed.The syntax is as follows −const type identifier = valueFor ... Read More

Decimal to Binary conversion using C Programming

Bhanu Priya
Updated on 08-Mar-2021 06:05:08

3K+ Views

ProblemHow to convert a decimal number to a binary number by using the function in the C programming language?SolutionIn this program, we are calling a function to binary in main(). The called function to binary will perform actual conversion.The logic we are using is called function to convert decimal number to binary number is as follows −while(dno != 0){    rem = dno % 2;    bno = bno + rem * f;    f = f * 10;    dno = dno / 2; }Finally, it returns the binary number to the main program.ExampleFollowing is the C program to ... Read More

Advertisements