Found 1439 Questions for C

What are the C Tokens?

Bhanu Priya
Updated on 03-Sep-2021 06:30:51
The C program is a collection of instructions and each instruction is a collection of individual units.Every small individual unit of a C program is generally called as token and every instruction in a C program is a collection of tokens.Tokens are used to construct the C programs and they are also said to be the basic building blocks of a C program.In a C program, tokens contain the following −KeywordsIdentifiersOperatorsSpecial SymbolsConstantsStringsData valuesIn a C program, a collection of all these keywords, identifiers, operators, special symbols, constants, strings, and data values are called tokens.ExampleFollowing is the C program to print ... Read More

What is program development cycle in C language?

Bhanu Priya
Updated on 03-Sep-2021 06:27:49
When we want to develop a program by using any programming language, we have to follow a sequence of steps. These steps are called phases in program development.The program development life cycle is a set of steps or phases which are used to develop a program in any programming language.Phases of program developmentProgram development life cycle contains 6 phases, which are as follows −Problem Definition.Problem Analysis.Algorithm Development.Coding & Documentation.Testing & Debugging.Maintenance.These six phases are depicted in the diagram given below −Problem DefinitionHere, we define the problem statement and decide the boundaries of the problem.In this phase, we need to understand ... Read More

Differentiate between int main and int main(void) function in C

Bhanu Priya
Updated on 02-Sep-2021 13:38:52
int main represents that the function returns some integer even ‘0’ at the end of the program execution. ‘0’ represents the successful execution of a program.The syntax of int main is as follows −int main(){    ---    ---    return 0; }int main(void) represents that the function takes NO argument. Suppose, if we don’t keep void in the bracket, the function will take any number of arguments.The syntax of int main(void) is as follows −int main(void){    ---    ---    return 0; }Actually, both seem to be the same but, int main(void) is technically better as it clearly ... Read More

What are string searching functions in C language?

Bhanu Priya
Updated on 02-Sep-2021 13:34:32
The library also provides several string searching functions, which are as follows −char *strchr (const char *string, intc);Find first occurrence of character c in string.char "strrchr (const char "string, intc);Find last occurrence of character c in string.char *strpbrk (const char *s1, const char *s2);returns a pointer to the first occurrence in string s1 of any character from string s2, or a null pointer if no character from s2 exists in s1.size_t strspn (const char *s1, const char *s2);returns the number of characters at the beginning of s1 that match s2.size_t strcspn (const char *51, const char *s2);returns the number of ... Read More

What are memory operations in C language?

Bhanu Priya
Updated on 02-Sep-2021 13:20:50
The library #include contains the basic memory operations. Although not strictly string functions, the functions are prototyped in #include .These memory operations are as follows −void *memchr (void *s, int c, size_t n);Search for a character in a buffer.int memcmp (void *s1, void *s2, size_t n);Compare two buffers.void *memcpy (void *dest, void *src, size_t n);Copy one buffer into another.void *memmove (void *dest, void *src, size_t n);Move a number of bytes from one buffer to another.void *memset (void *s, int c, size_t n);Set all bytes of a buffer to a given character.Note that in all case to bytes of memory ... Read More

What is conditional compilation in C language?

Bhanu Priya
Updated on 02-Sep-2021 13:19:11
In C programming language, several directives control the selective compilation of portions of the program code. They are as follows −#if#else#elif#endifThe general form of #if is as follows −#if constant_expression    statement sequence #endif#else works much like the C keyword else.#elif means "else if" and establishes an if else-if compilation chain.Amongst other things, #if provides an alternative method of "commenting out" code.For example, #if 0    printf("#d", total); #endifHere, the compiler will ignore printf("#d", total);#ifdef and #ifndef#ifdef means "if defined", and is terminated by an #endif.#indef means "if not defined".#undef#undef removes a previously defined definition.#line#line changes the contents of __LINE__ ... Read More

Differentiate between array and structures in C

Bhanu Priya
Updated on 02-Sep-2021 13:17:30
The major differences between an array and a structure in C programming language are as follows −ArraysStructuresAn array is a single entity representing a collection of data items of same data types.A structure is a single entity representing a collection of data items of different data types.Individual entries in an array are called elements.Individual entries in a structure are called members.An array declaration reserves enough memory space for its elements.The structure definition reserves enough memory space for its members.There is no keyword to represent arrays but the square braces [] preceding the variable name tells us that we are dealing ... Read More

C program to store inventory system using structures

Bhanu Priya
Updated on 01-Sep-2021 13:18:41
Structure is a collection of different datatype variables, grouped together under a single name.Features of structureThe features of structure in the C programming language are as follows −It is possible to copy the contents of all the structure elements of different datatypes to another structure variable of its type by using an assignment operator.For handling the complex datatypes, it is better to create structure within another structure, which is called nested structures.It is possible to pass an entire structure, individual elements of structure and an address of structure to a function.It is possible to create structure pointers.ProgramFollowing is the C ... Read More

C program to sort names in alphabetical order using structures

Bhanu Priya
Updated on 01-Sep-2021 13:27:01
Structure is a collection of different datatype variables, grouped together under a single name.Features of structureThe features of structure in the C programming language are as follows −It is possible to copy the contents of all the structure elements of different datatypes to another structure variable of its type by using an assignment operator.For handling the complex datatypes, it is better to create structure within another structure, which is called nested structures.It is possible to pass an entire structure, individual elements of structure and an address of structure to a function.It is possible to create structure pointers.Declaration and initialization of ... Read More

C program to compare if the two matrices are equal or not

Bhanu Priya
Updated on 01-Sep-2021 13:13:28
The user has to enter the order of two matrices and elements of two matrices. Then, these two matrix are compared.If both matrix elements and size are equal, then it displays that the two matrices are equal.If size of matrix is equal but the elements are not equal, then it displays that the matrix can be compared but is not equal.If the size and elements are not matched, then it displays that the matrices cannot be compared.ProgramFollowing is the C program to compare if the two matrices are equal or not −#include #include main(){    int A[10][10], B[10][10]; ... Read More
Advertisements