Bhanu Priya

Bhanu Priya

1,060 Articles Published

Articles by Bhanu Priya

Page 90 of 106

What is an anagram in C language?

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2021 4K+ Views

Anagram strings are nothing but, all the characters that occur for the same number of times in another string, which we call as anagrams.A user enters two strings. We need to count how many times each letter ('a' to 'z') appears in them and then, compare their corresponding counts. The frequency of an alphabet in a string is how many times it appears in it.If two strings have same count of the frequency of particular alphabet then, we can say those two strings are anagrams.Example 1String 1 − abcdString 2 − bdacThese two strings have same letters which appear once. ...

Read More

C program to perform union operation on two arrays

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2021 15K+ 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

Read More

C Program find nCr and nPr.

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2021 18K+ Views

In C programming language, nCr is referred as the combination. nCr is the selection of r objects from a set of n objects, where the order of objects does not matter.nPr is referred as the permutation. nPr is arrangement of 'r' objects from a set of 'n' objects, which should be in an order or sequence.Permutations and combinations formulasThe formulas to find the permutation and combination of given numbers in C language are given below −nCr = n!/(r!*(n-r)!)nPr = n!/(n-r)!.The logic used to find nCr is as follows −result = factorial(n)/(factorial(r)*factorial(n-r));The logic used to find nPr is as follows −result ...

Read More

What is a simple assertion in C language?

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2021 340 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

C Program to find sum of perfect square elements in an array using pointers.

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2021 2K+ 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

C program to represent the numbers in spiral pattern

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2021 1K+ Views

The spiral pattern to represent the numbers is shown below −The logic applied to print the numbers in spiral pattern is as follows −for(i=1;i

Read More

C Program to display the numbers in X pattern

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2021 2K+ Views

Refer an algorithm given below for the C program to display the numbers in X pattern.AlgorithmStep 1: Start Step 2: Declare variables Step 3: Read number of rows Step 4: for loop satisfiesif(i==j || i+j==rows-1)print i+1Print " "Step 5: Print new line Step 6: StopThe logic to print numbers in X pattern is as follows −for(i=0;i

Read More

C program to find type of array entered by the user.

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2021 980 Views

ProblemWrite a C Program to find the array type which we need to check, whether the given elements in an array are even numbers or odd numbers or combination of both.SolutionSo, user has to enter an array of integers, then, display the type of the array.Example 1 − Input: 5 3 1, Output: odd array.Example 2 − Input: 2 4 6 8, Output: even array.Example 3 − Input: 1 2 3 4 5, Output: mixed array.AlgorithmRefer an algorithm given below to find the array type entered by the user.Step 1 − Read the size of array at runtime.Step 2 − ...

Read More

C program for testing the character type

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2021 1K+ Views

There are some predefined functions available in "ctype.h" library for analyzing the character input and converting them.Analysis FunctionsThe character analysis functions are listed below −FunctionChecks whether entered character isisalphaAn alphabet (or) notisdigitA digit (or) notisspace QA space, a newline (or) tabispunct (A special symbol (or) notislowerA lower case letter of alphabetisupper QAn upper case letter of alphabetisalphanumericAn alphabet/digit or notConverting FunctionsThe converting functions are listed below −FunctionConversiontolower()Converts an upper case alphabet to lower casetoupper QConverts a lower case alphabet to upper caseProgramFollowing is the C program for character analysis and conversion functions which are used to test the character type ...

Read More

C Program to check the type of character entered

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2021 9K+ Views

Write a program to find out that a given character is upper case, lower case, number or special character.SolutionIf an entered character is capital letter then, it displays the upper case.Example: Input =H Output: upper case letterIf an entered character is small letter then, it displays the lower case letter.Example: Input= g Output: lower case letterIf an entered character is number then, it displays the digit.Example: Input=3 Output: digitIf an entered character is a special character then, it displays the special character.Example: Input= & Output: special characterAlgorithmRefer an algorithm given below to find out that a given character is upper ...

Read More
Showing 891–900 of 1,060 articles
« Prev 1 88 89 90 91 92 106 Next »
Advertisements