Posts

Showing posts from March, 2023

What are the Armstrong Numbers between 1 to 999?

Image
  Armstrong/Narcissistic Number:  If a number is equal to sum of each of its digits raised to power of its digits, it is said to be an Armstrong number or a  Narcissistic number . Ex: - 371 = 3 3 + 7 3 + 1 3 = 27 + 343 + 1 = 371 371 = 3 3 + 7 3 + 1 3 = 27 + 343 + 1 = 371 1634 = 1 4 + 6 4 + 3 4 + 4 4 = 1 + 1296 + 81 + 256 = 1634 1634 = 1 4 + 6 4 + 3 4 + 4 4 = 1 + 1296 + 81 + 256 = 1634 Why is 0 excluded in the question? 0 is also an armstrong number. Here’s a C++ program to find all the Armstrong numbers upto any given number //Armstrong numbers upto given number   #include<iostream>   #include <math.h>   using namespace std;     bool isArmstrong(double n)   {   int temp,digits=0,last=0;   double sum=0;   temp=n;     while(temp>0)   {   temp /= 10;   digits++;   }     temp = n;     while(temp>0)   {   last = temp%10;   sum += pow(last,digits);   temp /= 10;   }     if(n==sum) return true;   else return false;   }     int main()   {  

Why i should learn c++ programming language?

 Why i should learn c++ programming language? There are several reasons why learning C++ programming language can be beneficial: Versatility: C++ is a powerful, high-performance language that can be used in a wide range of applications, including desktop and mobile applications, video games, operating systems, and more. It's also used in industries like finance, healthcare, and aerospace. Performance: C++ is known for its high speed and efficiency. It allows programmers to write code that runs quickly and consumes minimal system resources, which is important for applications that require high performance. Control: C++ gives programmers more control over the hardware and memory resources of a system, which is important in certain applications like game programming, where performance is critical. Object-Oriented Programming (OOP): C++ supports OOP, which is a popular programming paradigm used to organize code and create reusable, modular software components. Learning OOP concepts can

Why you should learn programming?

  Why you should learn programming? Learning programming has many benefits, here are a few reasons why you should consider learning programming: High demand: Programming skills are in high demand across various industries. Many businesses and organizations are looking for individuals with programming skills to develop and maintain their software systems, websites, and applications. Career growth: Learning programming can help you advance in your career. With the demand for programmers, many opportunities are available in various fields such as healthcare, finance, education, and entertainment. Problem-solving skills: Programming requires a logical and analytical approach to solve problems. Learning programming can help you develop critical thinking and problem-solving skills that can be applied in many areas of your life. Creativity: Programming is a creative process. As you learn programming, you will find that you can create your own projects and software solutions. Understanding tec

What is Armstrong Number?

 What is Armstrong Number? 1. What is Armstrong Number? 2. Armstrong Number Logic 3. Armstrong number examples 4. Armstrong Number Algorithm 5. Python program to check Armstrong Number 6. Program To Find All The Armstrong Numbers Between 0 And 999 1) What is Armstrong Number? Beginners often wonder what is Armstrong number aka the narcissist number. It is of special interest to new programmers and those learning a new programming language because of the way the number behaves in a given number base. In numerical number theory, the Armstrong number is the number in any given number base, which forms the total of the same number, when each of its digits is raised to the power of the number of digits in the number. For example, using a simple number 153 and the decimal system, we see there are 3 digits in it. If we do a simple mathematical operation of raising each of its digits to the power of 3, and then totaling the sum obtained, we get 153. That is 1 to the power of 3 5

Popular posts from this blog

403. Scientific Problem - C++ / C - Solution - Codeforces ACMSGURU problemset

Version Control with Git: A Beginner’s Guide

Callback function in JavaScript