Found 33676 Articles for Programming

C++ Program To Convert Decimal Number to Binary

Nishu Kumari
Updated on 13-May-2025 16:58:31

5K+ Views

In a computer system, the binary number is expressed in the binary numeral system while the decimal number is in the decimal numeral system. The binary number is in base 2 while the decimal number is in base 10. Examples of decimal numbers and their corresponding binary numbers are as follows: Decimal Number ... Read More

C++ Program to Print Number Entered by User

karthikeya Boyini
Updated on 23-Jun-2020 16:36:19

5K+ Views

The objects “cin” and “cout” are used in C++ for input and output respectively. cin is an instance of the istream class and is attached to the standard input device such as the keyboard. cout is an instance of the ostream class and is connected to the standard output device such as the display screen.A program that prints the number entered by the user is as follows −Example Live Demo#include using namespace std; int main() {    int num;    coutnum;    cout

C++ Program to Check Whether a Number is Prime or Not

Nishu Kumari
Updated on 13-May-2025 16:59:42

4K+ Views

A prime number is a whole number greater than one and the only factors of a prime number should be one and itself. For example, 2, 3, 5, 7, and 11 are prime numbers. Our task is to write a C++ program that checks if a given number is prime or not. We will cover different approaches to solve this problem. We'll cover the following methods for checking whether a number is prime or not: Using a Simple Loop Using the Square Root Method Using ... Read More

C++ Program to Display Factors of a Number

Nishu Kumari
Updated on 13-May-2025 17:04:52

12K+ Views

A factor is a number that divides a given number completely without leaving a remainder. In this article, we'll show you how to display all the factors of a number using different methods in C++. For example, the factors of 12 are 1, 2, 3, 4, 6, and 12. In this article, we will look at two ways to find and display the factors of a number: Basic Iterative Approach Optimized Square Root Approach Factors of a Number Using Iterative (Basic) Approach In this approach, we use loop to go ... Read More

Python Program to print unique values from a list

Sarika Singh
Updated on 23-Nov-2022 08:24:42

3K+ Views

List is a built-in data structure in python which functions like a dynamically sized array. Lists are created by putting elements in square brackets ‘[element 1, element 2, ….]’. Elements present in list are indexed and the indexing starts from [0]. List has the following properties − List is mutable meaning that elements can be added, removed or changed from a list after its creation. List is ordered, so adding new elements to the list will not change the order of existing elements. List allows for entry of duplicate elements since each element has a unique index. A single ... Read More

C++ Program to Display Fibonacci Series

Samual Sam
Updated on 23-Jun-2020 16:24:22

16K+ Views

The fibonacci series contains numbers in which each term is the sum of the previous two terms. This creates the following integer sequence −0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377…….The recurrence relation that defines the fibonacci numbers is as follows −F(n) = F(n-1) + F(n-2) F(0)=0 F(1)=1Programs to Display Fibonacci SeriesThere are two methods to display fibonacci series i.e. using dynamic programming and recursive programming. These are further explained as follows −Dynamic ProgrammingExample#include using namespace std; void fib(int n) {    int f[n];    int i;    f[0] = 0;    f[1] ... Read More

Python program to sort a tuple by its float element

Sarika Singh
Updated on 23-Nov-2022 07:33:43

2K+ Views

This article will demonstrate how write a Python program to sort a tuple (made up of float elements) using its float elements. Here, we'll look at both how to sort using the in-built sorted() function and how to sort using the in-place method of sorting. Input-Output Scenarios Following is an input and its output scenario determining the sorting of a tuple by its float element − Scenario-1 Input: tuple = [(‘Dengu’, ’54.865’), (‘Malaria’, ‘345.743’), (‘Corona’, ‘456.864’), (‘Typhoid’, ‘35.285’), (‘Jaundice’, ’83.367’)] Output: [(‘Corona’, ‘456.864’), (‘Malaria’, ‘345.743’), (‘Jaundice’, ’83.367’), (‘Dengu’, ’54.865’), (‘Typhoid’, ‘35.285’)] In the above scenario we can see that ... Read More

Python Program to find mirror characters in a string

Sarika Singh
Updated on 23-Nov-2022 07:25:19

3K+ Views

This article teaches you how to write a python program to find mirror characters in a string. Let us first understand what mirror characters in a string are. Two identical alphabetically positioned characters, one from the front and the other from the back, are known as mirror characters. For example, the alphabet a's mirror character is "z, " "b's" is "y, " and so on. Input-Output Scenario Following is an input and its output example of mirror characters in a string − Input: p = 3 Input string = Coding Output: Cowrmt Here, the alphabets “d”, “i”, “n”, “g” ... Read More

Calendar function in Python

Samual Sam
Updated on 30-Jul-2019 22:30:23

2K+ Views

Python has an in built module called calendar which operation is related to calendar. There are some calendar functions in Python. calendar(year, w, l, c) This function shows the year, width of characters, no. of lines per week and column separations. Example print ("The calendar of 2014 is : ") print (calendar.calendar(2014, 3, 1, 4)) Output The calendar of year 2014 is : 2014 January ... Read More

Statistical Functions in Python

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

3K+ Views

Python has ability to solve the mathematical expression, statistical data by importing statistic keyword. Python can do various types of statistical and mathematical operations. These functions calculate the average value from a sample or population. mean () Arithmetic mean value (average) of data. harmonic_mean () Harmonic mean value of data. median () Median value (middle value) of data. median__low() Low median value of data. median__high() High median value of data. median__grouped() Median of the grouped data and also calculate the 50th percentile of the grouped data. ... Read More

Advertisements