
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1339 Articles for C

8K+ 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]

681 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

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

13K+ Views
Inline Function An inline function in C reduces function calls by expanding the function's code at the call site during compile time. This increases the efficiency of the function. The inline function can be substituted at the point of the function call, but this substitution is always the compiler's choice. In an inline function, the function call is replaced by the actual program code. Most Inline functions are ... Read More

4K+ 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

226 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

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

5K+ Views
A function is a self-contained block that carries out a specific task.The advantages of function in C language are as follows −ReusabilityThe length program can be reduced.It is easy to locate and isolate a wrong function.It facilitates top-down modular programming.ExampleFollowing is the C program for functions −#include /*Function prototypes*/ myfunc(); main(){ myfunc(); } /*Function Defination*/ myfunc(){ printf("Hello "); }Here, In calculations, we generally expect a function to return a value. But, it may or may not accept the arguments.This return value has a type int, float, char or anything else.Default type of function is integer.ExampleAnother program for the ... Read More

6K+ Views
Given a matrix, we need to print the boundary elements of the matrix and display their sum.ExampleRefer the matrix given below −Given matrix1 2 3 4 5 6 7 8 9Boundary Matrix1 2 3 4 6 7 8 9Sum of boundary elements: 1 + 2 + 3 + 4 + 6 + 7 + 8 + 9 = 40The logic to find the sum of boundary matrix is as follows −for(i = 0; i

19K+ Views
Take two integers from the user for base and exponent and calculate the power as explained below.ExampleConsider the following for writing a C program.Suppose base =3Exponent = 4Power=3*3*3*3AlgorithmFollow the algorithm given below −Step 1: Declare int and long variables. Step 2: Enter base value through console. Step 3: Enter exponent value through console. Step 4: While loop. Exponent !=0 i. Value *=base ii. –exponent Step 5: Print the result.ExampleThe following program explains how to calculate power of given number in C language.#include int main(){ int base, exponent; long value = 1; printf("Enter a base value: ... Read More