- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 1401 Articles for C
7K+ Views
Intersection operationIf array 1 = { 1,2,3,4,6} Array 2 = {1,2,5,6,7}Then, intersection of array1 and array 2 isArray1 ^ array 2 = {1,2,3,4,6} ^ {1,2,5,6,7} = {1,2,6}Set of common elements is called an intersection.The logic for intersection is as follows −k=0; for(i=0;i
12K+ Views
A union is a special data type available in C programming language that allows to store different data types in the same memory location. Unions provide an efficient way of using the same memory location for multiple-purpose.Union operationIf array 1 = { 1,2,3,4,6} Array 2 = {1,2,5,6,7}Then, union of array1 and array 2 isArray1 U array 2 = {1,2,3,4,6} U {1,2,5,6,7} = {1,2,3,4,5,6,7}Set of all elements without repetition is called union.The logic for union is as follows −for(i=0;i
57K+ Views
User has to enter number of names, and those names are required to be sorted in alphabetical order with the help of strcpy() function.An array of characters (or) collection of characters is called a string.DeclarationFollowing is the declaration for an array −char stringname [size];For example, char string[50]; string of length 50 characters.InitializationUsing single character constantchar string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}Using string constantschar string[10] = "Hello":;AccessingThere is a control string "%s" used for accessing the string till it encounters ‘\0’strcpy ( )This function is used for copying source string into destination string.The length of the destination string ... Read More
210 Views
An assertion is a statement which is used to declare positively that a fact must be true when that line of code is reached.Assertions are useful for obtaining the expected conditions which are met.Simple AssertionSimple assertion can be implemented by using assert (expression) method, which is present in assert.h header file.The syntax for simple assertion is as follows −assert(expression)In simple assertion, When the condition passed to an assertion which is a true, then, there is no action.The behaviour on false statements depends completely on compiler flags.When assertions are enabled, a false input causes a program to halt.When assertions are disabled, ... Read More
1K+ Views
ProblemWrite a program to find the sum of perfect square elements in an array by using pointers.Given a number of elements in array as input and the sum of all the perfect square of those elements present in the array is output.SolutionFor example, Input= 1, 2, 3, 4, 5, 9, 10, 11, 16 The perfect squares are 1, 4, 9, 16. Sum = 1 + 4 + 9 +16 = 30 Output: 30AlgorithmRefer an algorithm given below to find the sum of perfect square elements in an array by using pointers. Step 1 − Read number of elements in array at ... Read More
2K+ Views
ProblemWrite a program to find the sum of perfect square elements in an array.Given a number of elements in array as input and the sum of all the perfect square of those elements present in the array is output.SolutionFor example, Input= 1, 2, 3, 4, 5, 9, 10, 11, 16 The perfect squares are 1, 4, 9, 16. Sum = 1 + 4 + 9 +16 = 30 Output: 30AlgorithmRefer an algorithm given below to add the perfect square elements in an array.Step 1 − Read number of elements in array at runtime.Step 2 − Input the elements.Step 3 − ... Read More
9K+ Views
For swapping two strings from one location to another location, we use strcpy() function.An array of characters (or) collection of characters is called a string.DeclarationFollowing is the declaration for an array −char stringname [size];For example, char string[50]; string of length 50 characters.InitializationUsing single character constantchar string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}Using string constantschar string[10] = "Hello":;AccessingThere is a control string "%s" used for accessing the string till it encounters ‘\0’strcpy ( )This function is used for copying source string into destination string.The length of the destination string is greater than or equal to the source string.The syntax ... Read More
482 Views
ProblemWrite a C Program to find the array type that we need to check, whether the given elements in an array are even numbers or odd numbers or combination of both by using pointers.SolutionThe user has to enter an array of integers, then, display the type of the array.Example 1 − Input: 5 3 1, Output: odd arrayExample 2 − Input: 2 4 6 8, Output: even arrayExample 3 − Input: 1 2 3 4 5, Output: mixed arrayAlgorithmRefer an algorithm given below to find the array type entered by user with the help of pointers.Step 1: Read the size ... Read More