Sudhir sharma has Published 1206 Articles

C/C++ Program for Linear Search?

sudhir sharma

sudhir sharma

Updated on 20-Aug-2019 09:00:05

9K+ Views

In linear search algorithm, we compare targeted element with each element of the array. If the element is found then its position is displayed.The worst case time complexity for linear search is O(n).Input: arr[] = { 12, 35, 69, 74, 165, 54} Sea=165 Output: 165 is present at location 5.Explanationlinear ... Read More

C++ Program to find whether a number is the power of two?

sudhir sharma

sudhir sharma

Updated on 20-Aug-2019 08:57:26

2K+ Views

Check if a given number is a power of 2. First check below which numbers are the power of two or not. This code checks whether the number is odd and then divide it concurrently until it becomes 0 or odd. If it becomes 0 then it is a power ... Read More

C++ Program for cube sum of first n natural numbers?

sudhir sharma

sudhir sharma

Updated on 20-Aug-2019 08:55:36

305 Views

Positive integers 1, 2, 3, 4... are known as natural numbers.This program takes a positive integer from the user ( suppose user-entered n ) then, this program displays the value of 13+23+33+....+n3.Input: n = 3 Output: 36Explanation13+23+33 = 1 +8+27 = 36This program takes a positive integer from user( suppose ... Read More

C++ Program for Cycle Sort?

sudhir sharma

sudhir sharma

Updated on 20-Aug-2019 08:54:14

358 Views

Cycle sort is an in-place, unstable sorting algorithm, a comparison sort that is theoretically optimal in terms of the total number of writes to the original array, unlike any other in-place sorting algorithm. It is based on the idea that the permutation to be sorted can be factored into cycles, ... Read More

C Program to Find the minimum sum of factors of a number?

sudhir sharma

sudhir sharma

Updated on 20-Aug-2019 08:50:59

291 Views

The program to find the minimum sum of factors of a number. The logic for solving this problem is, find all the set of factors and adding them. For every set of factors, we will do the same and then compare all of them. Then find all the minimum of ... Read More

C Program to count the number of lines in a file?

sudhir sharma

sudhir sharma

Updated on 20-Aug-2019 08:49:43

7K+ Views

In this program, we are going to learn how to find the total number of lines available in a text file using C program?This program will open a file and read the file’s content character by character and finally return the total number of lines in the file. To count ... Read More

C Program to Compute Quotient and Remainder?

sudhir sharma

sudhir sharma

Updated on 20-Aug-2019 08:47:43

332 Views

Given two numbers dividend and divisor. The task is to write a program to find the quotient and remainder of these two numbers when the dividend is divided by the divisor.In division, we will see the relationship between the dividend, divisor, quotient, and remainder. The number which we divide is ... Read More

C Program To Check whether Matrix is Skew Symmetric or not?

sudhir sharma

sudhir sharma

Updated on 20-Aug-2019 08:44:46

3K+ Views

Square Matrix A is said to be skew-symmetric if aij=−aji for all i and j. In other words, we can say that matrix A is said to be skew-symmetric if transpose of matrix A is equal to negative of Matrix A i.e (AT=−A).Note that all the main diagonal elements in ... Read More

C Program to Check if count of divisors is even or odd?

sudhir sharma

sudhir sharma

Updated on 20-Aug-2019 08:34:59

264 Views

Given a number “n” as an input, this program is to find the total number of divisors of n is even or odd. An even number is an integer that is exactly divisible by 2. Example: 0, 8, -24An odd number is an integer that is not exactly divisible by ... Read More

C Program for Program for array rotation?

sudhir sharma

sudhir sharma

Updated on 20-Aug-2019 08:33:41

3K+ Views

Write a C program to left rotate an array by n position. How to rotate left rotate an array n times in C programming. Logic to rotate an array to left by n position in C program.Input: arr[]=1 2 3 4 5 6 7 8 9 10 N=3 Output: 4 ... Read More

Advertisements