C++ Program to Check given number is Armstrong number or not
#include<iostream>
#include<iomanip>
int main(){
int num,r,sum,temp;
for(num=1;num<=500;num++){
temp=num;
sum = 0;
while(temp!=0){
r=temp%10;
temp=temp/10;
sum=sum+(r*r*r);
}
if(sum==num)
cout << num << setw(2);
}
return 0;
}---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Write a C++ program to Make Simple calculator
- Write a C++ program to arrange 10 numbers in ascending order
- Write a C++ program to calculates the following equation for entered numbers (n, x). 1+ (nx/1!) - (n(n-1)x^2/2!)
- Write a C++ program to 1. Initialize Matrices 2. Print Matrices 3. Multiply Matrices 4. Transpose of 2nd Matrix 5. Move Row and Column of 2nd Matrix 6. Quit
- Write the C++ program for processing of the students structure
- Write a C++ program that gets two strings from input and stores them in variables such as str1 and str2
- Write a C++ program that gets one text with the maximum of 256 characters from input and converts it to standard format based on the following rules and prints the final standardized text
- C++ Mini-Project: Human Resource Management Program
- Write a C++ program to Solve Quadratic equation
- C++ program for Calculation of the surface and the volume of a cone
- C++ Program to show Fibonacci Series
- C++ Program for Decimal to Hexadecimal Conversion
- C++ program to convert decimal number into binary
- C++ PROGRAM TO CHECK WHETHER A NUMBER IS NOT A PERFECT NUMBER OR NOT
- C++ program to find prime numbers in a given range
- C++ program to find Armstrong number
- C++ program to find prime number
- C++ program to convert a string into upper-case or lower-case
- C++ program to concatenate strings
- How to Run and install the mongo c++ drivers (MongoDB) On Ubuntu Linux
- How to Install Crypto++ Library with the Eclipse IDE on UBUNTU12.10 OS.
- Build and Run Sample Code Using Log4Cpp from Source Code on Ubuntu
- C++ counting the number of lines in a text file
- How do you implement the factorial function in C++
- C++ program to find HCF n LCM of two numbers
- The most elegant way to split a string in C++
- C++ Program for Printing 1 to 1000 without loop
- PASS BY REFERENCE C++ EXAMPLE
- C++ PROGRAM TO FIND WHETHER A NUMBER IS EVEN OR ODD
- C++ code to print all odd and even numbers in given range
- C++ Program to Check Palindrome Number
- C++ code to get sum of all odd numbers in given range
- C++ program to find ASCII Code for Characters and numbers
- Compiling and Integrating Crypto++ into the Microsoft Visual C++ Environment + Running Sample program
- Write a c++ program that calculates the average of three numbers
- C++ program compute hourly pay taking overtime into account
- C++ program to print 5 rows of 10 stars
- Write a C++ program that can print a temperature conversion
- Write a C++ program to construct a pyramid of stars
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
You have amazing blog
ReplyDeleteI have four questions for c++
can you help me solve all the four
please,
regards,
Post the questions ...I will try to help you
DeleteThere are five questions you can try four of them because am working in the last one>
ReplyDeleteI really appreciate your help.
I am using visual studio , c++ language.
Problem 1: Navi Language
Dr. Smith, a linguistics professor, has recently published a book written in the Navi language. The language uses a subset of the English characters. However, the ordering of these characters is quite different from that of the English alphabet. For example, the letter A may come after H, and X may come before C, etc. Similar to other books, this book needs an index table in the back of the book, and the index must be ordered by the lexical order of the Navi language. You will be given the order of letters in the Navi language and a list of key words that have appeared in the book. You are to write a program that will generate the index table for the key words based on the given letter order.
Input
The first input line contains letters of the Navi language, from lowest order to the highest order. Only uppercase letters will be given and there is a blank space between two letters. The following input lines contain a list of words in lowercase letters, one word per line and the list is ended with ‘@’. You may assume that each word can be at most 15 characters long, and there are at most 50 words.
Output
Your program should print the words in lexical order. Same as any index table, the first letter of each word should be capitalized.
Sample Input
C M H B F
hccbmf
mhc
hccfc
cfh
hbcf
mbc
@
Sample Output
Cfh
Mhc
Mbc
Hccbmf
Hccfc
Hbcf
Problem 2: Armstrong and Perfect Numbers
ReplyDeleteMore than 2500 years ago, mathematicians got interested in numbers.
Armstrong Numbers: The number 153 has the odd property that 13+53 + 33 = 1 + 125 + 27 = 153. Namely, 153 is equal to the sum of the cubes of its own digits.
Perfect Numbers: A number is said to be perfect if it is the sum of its own divisors (excluding itself). For example, 6 is perfect since 1, 2, and 3 divide evenly into 6 and 1+ 2 + 3 = 6.
Input
Up to 50 numbers, stored in an array.
Output
Print the perfect numbers
Print the Armstrong numbers.
Hint: use functions !
Sample Input
153 6 26
Sample Output
Perfect Numbers are: 6
Armstrong numbers are: 153
Problem 3: Apples Eater
ReplyDeleteMr. Apple loves to eat apples, but he eats apples in a rather strange way. Mr. Apple arranges his apples in a circle, numbers them, and then he eats every other next apple. The last remaining apple he keeps to make apple pie. The following diagram shows how Mr. Apple picks the last apple, assuming there are 5 apples:
Input
Each input line contains one integer n, where n is the number of apples (1 ≤ n ≤ 99999).
Output
Print the number of apples followed by one space followed by the number of the last apple left
Sample Input
5
Sample output
5 3
Problem 4: Subset Sums
ReplyDeleteGiven a set of positive integers S, find all subsets of S, such that the sum of elements of each subset equals to a given integer n.
Input
Every line contains a distinct positive integer, the set S terminates when 0 is found, followed by the value sum.
Output
For each data set, output the subsets whose sum is equal to sum, elements separated by a space, each subset is separated by an empty line.
Sample Input
4
2
7
5
9
0
11
Sample Output
2 4 5
2 9
4 7
ReplyDeleteProblem 5: Climbing Worm
An inch tall worm is at the bottom of a well n inches deep. It has enough energy to climb u inches every minute, but then has to rest a minute before climbing again. During the rest, it slips down d inches. The process of climbing and resting then repeats. How long before the worm climbs out of the well? We'll always count a portion of a minute as a whole minute and if the worm just reaches the top of the well at the end of its climbing, we'll assume the worm makes it out.
You are required to implement two functions:
1) Function to check that the inputs of the user obey to the assumption that d < u and n < 100
2) A function that returns the number of minutes needed for the worm to climb the well.
Input The user enters 3 positive integers n, u and d. These give the values mentioned in the paragraph above. Furthermore, you may assume d < u and n < 100.
Output an integer indicating the number of minutes it takes for the worm to climb out of the well.
Sample Input
10 2 1
Sample Output
17
Thank you SO MUCH for your time
Am really wating for your help , please
ReplyDelete/*
ReplyDelete1049 Climbing Worm
Time Limit : 1000 ms Memory Limit : 32768 K Output Limit : 5120 K
GUN C++
*/
#include
using namespace std;
int main()
{
int n,d,u,ians;
while(cin>>n>>u>>d && (n!=0))
{
ians=0;
while(n-u>0)
{
n=n-u+d;
ians+=2;
}
ians++;
cout<<ians<<endl;
}
return 0;
}
Hello Dear,
ReplyDeleteI did not have time to thank you enough for your help.
Thank you ,
Thank you so much.
and added one more blog to my favourit list. ^^
Your blog is FASCINATING