C++ :: Find Next Palindrome Number Larger Than Input Number
Nov 14, 2014
Q. WAP to find the next palindrome number larger than the input number.
for eg:-
Input=25
Output=33
The program is giving correct output for number with all digits '9';
why is it not giving output.
#include<iostream>
#include<string>
using namespace std;
int main() {
int len,flag=1,count=0,num,ind;
[code]....
View 8 Replies
ADVERTISEMENT
Nov 25, 2014
#include <stdio.h>
#include <iostream>
#include <cstdlib>
[Code]....
View 1 Replies
View Related
Oct 8, 2014
Write a C++ program that will input from the user a positive number n and find its factorial. Don’t forget to validate the input. The factorial of a positive integer n (denoted by n!) is defines as the product of the integers from 1 to n.
n! = 1* 2 * 3 * ... * (n - 1) * n
You should allow the user to continue working with your program for additional data sets.
Sample output:
Please enter a number: 5
5! = 120
Would you like to continue (Y/N)?Y
Please enter a number: 3
3! = 6
Would you like to continue (Y/N)?N
Good Bye!!
My code for what i think I'm doing is as follows:
#include <iostream>
using namespace std;
int main(){
int i=1;
int n;
[Code] ....
View 1 Replies
View Related
Apr 21, 2014
find the prime factors of the number input by the user. This time, we are going to have the user input a number, and the program will find all prime numbers from 2 to that number and prime factors of the number input by the user
#include <iostream>
#include <cmath>
using namespace std;
[Code]......
View 5 Replies
View Related
Feb 12, 2014
I could not find the mistake in this program....
Code:
//cpp program to check whether a number is palindrome or not
#include<iostream.h>
#include<conio.h>
//the class
class palindrome
[Code] ....
View 4 Replies
View Related
Apr 20, 2015
I want to find number of comparison and number of exchanges from a list or other than a list. My list is this
12 5 11 19 4 7 8 10 9 6 22 2 9 1 32
First, I am looking for number of comparisons from a list of 10 numbers with 21inversions made by selection sort, insertion sort, exchange sort.
Also, I like to find number of exchanges from a list of 10 numbers with 21inversions made by selection sort, insertion sort, exchange sort.
View 6 Replies
View Related
Aug 20, 2014
In the c pgm to find number of digits , if I am giving 001 as the input number ,why I am not getting the no. of digits as 3?
View 2 Replies
View Related
Feb 19, 2015
I'm trying to determine the number of times I have to change each specific character in a string to make it a palindrome. You can only change a character one at a time from the end.
Example: "abc" -> "abb" -> "aba" should print 2. "aba" will print 0 because it's already a palindrome. "abcd" -> "abcc" -> "abcb" -> "abca" -> "abba" will print 4 because it took 4 changes to make a palindrome.
I'm not too sure how to approach this - I figured out the case where if it's a palindrome (if reversed string is the same) then it'll print out a 0.
int main() {
int number;
cin >> number; //expecting a number for first line user input
for (int i = 0; i < number; i++) {
string str;
[Code] ....
View 1 Replies
View Related
Apr 26, 2013
I need to write a code in c++ , to input decimal number and the output to be number in Scientific notation with 32 bits .
View 1 Replies
View Related
Jul 15, 2014
I am trying to find the max number entered by the user, and it should terminate when a negative number is entered. For my code, it will just end when the user inputs a lower number than the previous. i.e.- 10 20 15 "The highest number is 20" when it should be "10 20 5 40 15 -1" "The highest number is 40". No arrays or do/while loops either.
#include <iostream>
using namespace std;
int Max(int x);
int main() {
int x;
[Code] ....
View 9 Replies
View Related
Mar 23, 2013
I have to write a program that will ask you to put in a number between 0 and 9 and multiply it by pi. If the number put in is between 0 and 9 then pi is multiplied but if it isnt between 0 or 9, it will say the number is not between 0 and 9 and asks you to put it in again and will repeat until a number between 0 and 9 is put in.
I have got the program working to the extent that it the number is between 0 and 9 it will multiply it by pi but if its not between 0 and 9 it will say the number is not between 0 and 9 and ask to put in a new number.
I can't work out how to get the program to repeat itself if the number entered isnt between 0 and 9.
I have enclosed the code below .....
View 5 Replies
View Related
Dec 2, 2013
how to get this program to find the palindrome? Here is my program:
#include <iostream>
#include <string>
using namespace std;
using std::string;
[code].....
View 2 Replies
View Related
Apr 3, 2013
here is the link to question: [URL] ....
below is my code:
friendship relations #48.cppfriendship relations #48.cpp
I have some question in regards to the b part 2. My code is working fine when the number of input is low. However when I input more larger input data to my program it start to hangs.
Here is the input: [URL] ....
Output: [URL] ....
View 1 Replies
View Related
Sep 25, 2014
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
void findPalind(char *arr) {
int i,j,n,odd,flag=0,count[26]={0};
[Code] ....
This question was asked in Hackerrank. [URL] ....
I am able to get correct output upto a input of 50000 character string, but not for 100000 character string.
View 12 Replies
View Related
Mar 6, 2015
I am entering numbers to float ... I want program to find out, which first number is not from specific interval. How to do it ? Example: Enter input : 5 10 20 30 50 46 . 30 is invalid. Here is the code :
Code:
while(scanf("%f",&input)!=EOF || input==0) {
sum=input+sum;
if (getchar() == '
[Code]....
View 3 Replies
View Related
Apr 11, 2015
I'm having this issue where my else if statements are not working. My program only works correctly when I go into my if statement and change the first part of my array to the specific row I am trying to find ex [0][i] to [1][i].
int getMonthMax(int scores[][COLS],int month){
int highestN=0,i, j;
for (i=0;i<ROWS-1;i++){
if(scores[0][i]>highestN){
highestN=scores[0][i];
[Code] .....
View 4 Replies
View Related
Aug 3, 2014
Write a function which takes string of integer numbers and length of a string. Function need to return value of element which is close to mean of all numbers and transform string without that element. If are more numbers in same "distance" of mean, function need to find first and throw that number-element.
In function without []..
with pointers.
I wrote this code below, programm find mean of elements and if mean is equal to any element of string.. the programm return that number. Idk how to delete that number and how to find closest.. for ex:
String=[4,7,10,3]
sum=24
mean=6
The progoramm need to delete 7 and new string look like String=[4,10,3]
insert Code:
#include <stdio.h>
int main()
{
int n,i;
printf("Elements of string ?
[Code]....
View 9 Replies
View Related
Jul 26, 2013
Its a code to find the largest number of a 3X3 matrix.The logic seems to be right........
Code:
#include<stdio.h>
main() {
int matrix[3][3],i,k,j,*a;
a=&matrix[0][0];
printf("Enter the elements");
for(i=0;i<=2;i++) {
[Code]....
View 7 Replies
View Related
Nov 25, 2013
how i can find the 5 without loop?
vector<int>i;
vector<int>j;
i.push_back(1);
i.push_back(2);
j.push_back(3);
j.push_back(4);
j.push_back(5);
[Code]...
View 10 Replies
View Related
Oct 21, 2014
I need to generate a grid of 10x8 and fill it with random numbers (max 70), then i need to find the smallest number within the random numbers generated and my "findSmallest" function does not seem to work and i do not know how to make it work...
Here my Code:
include <iostream>
using namespace std;
int main() {
int row=0;
int col=0;
int ArrayGrid [9][11];
srand(time(NULL));
[Code] .....
View 4 Replies
View Related
Nov 28, 2013
How to find the smallest number amongst 4 numbers
View 10 Replies
View Related
Oct 23, 2014
I'm trying to find the second smallest number out of 4 numbers. I produced some code that does that but it doesn't work if i have duplicate numbers.
secondSmallest = a;
if(b > secondSmallest) {
secondSmallest = b;
}
if(c < secondSmallest) {
[Code] ....
View 1 Replies
View Related
Oct 18, 2014
Write a program that will find the smallest, largest and average of the values in a collection of N positive integer numbers.
View 12 Replies
View Related
Nov 22, 2013
I have been struggling with this program. I am somewhat new to c and suck at logic. I have a personal program I want to make that I will try to get extra credit for in school. I have a printed set of winning lottery numbers form the last 10 years. I chose the easiest one do do logically which is just 5 numbers none repeating.
I am trying to find out how I can print the least common 10 sets. I think if there are any set which have not been picked I would have to print all of those because logically they would all be equal, then print sequentially the sets least picked up to 10.
I have pseudocode which I am sure is wrong but will post it just to show that I am trying. My first attempt was to add the numbers but quickly realized that that wouldn't work ...
5 Nums Pseudocode
Code:
Read Nums
Parse Into Ints
Make Array [185] //39+38+37+36+35 The highest the numbers added together can go
//LOGIC
[Code] ....
View 5 Replies
View Related
Nov 15, 2014
I use rand function to generate a number which consists of 3-5 digits(e.134,1435,73463..). The user decides whether he wants a 3 digit,4 digit or 5 digit number.After that,the user tries to guess the number.Its like mastermind game.The user will enter a number (with the same amount of digits) and the program will calculate how many digits from the secret number he has found and also how many digits he has found in the correct position(e.if the generatir produces the number 32541 and the user tries the number 49581 the program should tell him that he found 3 digits (5,1,4) and 2 digits in the correct position(5,1)) so that after some tries he finds the secret number.My problem is with the functions so that i can compare the digit of each number,find the amount of same digits and the amount of digits in same position.
View 5 Replies
View Related
Feb 10, 2015
i want to write a program which find the biggest prime factor of a number for example the biggest prime factor of six is three or the biggest prime factor of fifteen is five. What is my program bug
Code:
#include <stdio.h> // main functions
#include <math.h> // for sqrt function
int main()
{
int i, j, k, f; // F = Flag;
printf("Enter K
[Code]...
View 9 Replies
View Related