Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
C Articles
Page 68 of 96
Array elements that appear more than once in C?
Array is a container of elements of Same data types length needs to be defined beforehand. And an element can appear in any order and any number of times in an array. so in this program we will find elements that appear more than once in an array.Problem description − We have given an array arr[] in which we have to find which of the element are repeating in the array an app to print them.Let’s take an example to understand this better.Example, Input: arr[] = {5, 11, 11, 2, 1, 4, 2} Output: 11 2ExplanationWe have an array arr ...
Read MoreC Program for Armstrong Numbers
We are given a task where we have to check a number n entered by the user, whether it's Armstrong or not. An Armstrong number is when the sum of all the digits power by the number of digits or we can say order of digits n, is same as the digit. So below is a simple representation how to find the Armstrong number − Formula − wxyz…. = pow(w, n) +pow(x, n) + pow(y, n) + pow(z, n) + …. Algorithm START Step 1-> Declare a function to find the value ...
Read MoreC Program for Area And Perimeter Of Rectangle
Given a length and breadth of a rectangle we have to find its area and Perimeter.Rectangle is 2-D figure containing four sides and four angles of 90 degree each. All the sides of rectangle are not equal only the opposite sides of a rectangle are equal. The diagonals in a rectangle also are of the same length.Below is a diagrammatic representation of rectangle.Here A represents the breadth and B represents length of the rectangle.To find the Area of a rectangle the formula is: Length x BreadthAnd Perimeter of a rectangle is − 2 x (Length+Breadth).ExamplesInput: 20 30 Output: area of rectangle ...
Read MoreC Program for n-th odd number
Given a number N we have to find the N-th odd number.Odd numbers are the numbers which are not completely divided by 2 and their remainder is not zero. Like 1, 3, 5, 7, 9, ….If we closely observe the list of even numbers we can also represent them as(2*1)-1=1, (2*2)-1=3, ( 2*3)-1=5, (2*4)-1=7, ….(2*N)-1.So, to solve the problem we can simply multiply the number N with 2 and subtract 1 from the result, that makes up an odd number.ExamplesInput: 4 Output: 7 The 4th odd number is 1, 3, 5, 7.. Input: 10 Output: 19AlgorithmSTART STEP ...
Read MoreC Program for n-th even number
Given a number N we have to find the N-th even number. Even numbers are the numbers which are completely divided by 2 and their remainder is zero. Like 2, 4, 6, 8, 10, …. If we closely observe the list of even numbers we can also represent them as 2*1=2, 2*2=4, 2*3=6, 2*4=8, ….2*N. So, to solve the problem we can simply multiply the number N with 2, so the result will be the number which is divisible by 2, i.e. the even number. Example Input: n = 4 Output: 8 The first ...
Read MoreProgram to Convert Radian to Degree in C
If input is in radian convert it to degree else input will be in radian convert it to degree. There are formulas that can be used for this conversion. Radian is the standard unit for measuring angles whereas the complete angle of circle is divided into 360 degree. Also, radian is the smaller value as 1 degree = 180 radians. Conversion Formulas − degree = radian * (180/pi) where, pi=3.14 or 22/7 Example Input-: radian = 9.0 Output-: degree is : 515.92357 Algorithm Start Step 1 -> define macro as #define pi 3.14 ...
Read MoreC Program to Minimum and Maximum prime numbers in an array
Problem statementGiven an array of n positive integers. We have to find the prime number with minimum and maximum value.If the given array is −arr [] = {10, 4, 1, 12, 13, 7, 6, 2, 27, 33} then minimum prime number is 2 and maximum prime number is 13Algorithm1. Find maximum number from given number. Let us call it maxNumber 2. Generate prime numbers from 1 to maxNumber and store them in a dynamic array 3. Iterate input array and use dynamic array to find prime number with minimum and maximum valueExample#include #include #include #define SIZE(arr) (sizeof(arr) ...
Read MoreProgram for Identity Matrix in C
Given a square matrix M[r][c] where 'r' is some number of rows and 'c' are columns such that r = c, we have to check that 'M' is identity matrix or not. Identity Matrix Identity matrix is also known as Unit matrix of size nxn square matrix where diagonal elements will only have integer value one and non diagonal elements will only have integer value as 0 Like in the given Example below − $$I1=\begin{bmatrix}1 \end{bmatrix}, \ I2=\begin{bmatrix}1 & 0 \0 & 1 \end{bmatrix}, \ I3=\begin{bmatrix}1 &0 & 0 \0 &1 & 0 \0 &0 &1 ...
Read MoreProgram to Convert Centimeter to Feet and Inches in C
Given with the length into centimeter as an input, the task is to convert the given length into feet and inches We can use length conversion formula for this − 1 feet = 30.48 cm 1 inche = 2.54 cm Example Input-: centimetre = 100 Output -: Length in meter = 3m Length in Kilometer = 0.003km Algorithm Start Step 1 -> Declare function to perform conversion double convert(int centimeter) set double inch = 0.3937 * centimetre set double feet = 0.0328 * centimetre ...
Read MoreProgram to Calculate the Perimeter of a Decagon in C program
What is Decagon?Given with side, the task is to calculate the perimeter of decagon. Decagon is a type of polygon with 10-sides that’s why it is also known as 10-gon polygon. It have 10 vertices and edges. A regular decagon has sides of equal length and each internal angle of degree 144.Given below is the figure of DecagonTo calculate the volume and surface area of Frustum of cone there is a formulaPerimeter = 10 * SideExampleInput-: side=10 Output-: perimeter of Decagon is : 100 Input -: side = 20 Output -: perimeter of Decagon is : 200AlgorithmStart Step 1 ...
Read More