C++ :: CPP Program To Check Whether A Number Is Palindrome Or Not?

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


ADVERTISEMENT

C :: Program To Check If Phrase Is Palindrome Or Not

Nov 8, 2013

I get this error..In function 'main':

p6.c.text+0x6a): undefined reference to 'palindromeness'
collect2: 1d returned 1 exit status

This is program is suppose to check if a phrase is a palindrome or not.I need to write a function definition for _Bool palindromeness(char str[])but I am having a tough time figuring that part out. I am brand new to programming..this is my first class and I am just learning arrays and pointers.

View 4 Replies View Related

C++ :: Program To Check Whether Or Not A String Is Palindrome

May 20, 2013

So I've been tasked with creating a program that checks to see whether or not a string is a palindrome. It has to remove whitespace, punctuation, and capitalization for obvious reasons. Getting some errors which I'm not sure how to correct.

On an unrelated note, while programming in the console, my cursor has turned into a gray box and replaces characters when typing, instead of pushing them forward, etc. How do I return it to normal?

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
bool isPalin(string& palin);
string cleanUp(string& palin);

[Code] .....

View 7 Replies View Related

C++ :: Check A String To Be Palindrome

Apr 23, 2014

I am trying to check a string to be a palindrome. I have tried using for loop but I am looking for most efficient way.

View 5 Replies View Related

C/C++ :: Program To Check Number Is Prime Or Not

Jan 12, 2013

What is the minimum range of numbers which we need to go necessarily to check either a number is prime or not?(for all integers) ....

View 6 Replies View Related

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 View Related

C++ :: Determine Number Of Times Change Each Specific Character In String To Make It Palindrome

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

C++ :: Program That Checks Whether A String Is Palindrome

Apr 27, 2014

Write a program that checks whether a string is a palindrome. A palindrome is a word, phrase, orsequence that can be read the same backward and forward.

Code:
#include<iostream>
#include<string>
using namespace std;
int main(){

[Code] .....

View 2 Replies View Related

C++ ::  Palindrome Program Compile Error

Jan 16, 2014

Here is the code which I wrote in Turbo C++...its giving errors..

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
voidmain() {
clrscr();

[code]....

View 8 Replies View Related

C/C++ :: Palindrome Program - Cstrings Using Strtok Function

Feb 28, 2014

I had an assignment to do a palindrome program but im stuck in this part.

"This c-string will be sent to a function that will remove all spaces and punctuation marks from its c-string as well as change any uppercase letters to lowercase. Use string tokens to eliminate the spaces & punctuation marks. Make sure you include the NULL as you concatenate the tokens into a c-string. Then copy back into the original c-string for the pass by reference."

void tokenptr(char drome[]) {
char *token;
size_t i;
token = strtok(drome, " ,.!:;?");
while (token != '') {

[Code] .....

I'm pretty sure I did that part except how can i pass this cstring back to main? We really haven't even touched much of pointers except to use strtok().

View 2 Replies View Related

C++ :: Palindrome - Program Goes Into Infinite Loop Whenever Word With White Spaces Added

Feb 9, 2013

I have an assignment where i have to make a palindrome program. As you can see i have already done the basic palindrome prog, however i am now stuck since the program goes into a infinite loop whenever a word with whitespaces is added.

I have also tried searching for methods online however they do not seem to work for me...

void CPali::check() {
length = strlen(palin);
for (int i = 0, p = length-1; p>i; i++, p--) {
if (palin[i] == ' ')

[Code] ....

View 6 Replies View Related

C++ :: Negative Number Check

Sep 30, 2013

The code on lines 44-53 is suppose to display a message when the user enter a negative number, however, when a correct positive number is entered the message is display again.

#include<iostream>
#include<cctype>
using namespace std;
int main() {
char carType;
int A, B, C;

[Code] ....

View 2 Replies View Related

C :: Check Number Of Elements In Array

Apr 7, 2014

I can have at most 3 structs in array, but it could be 0,1,2 or 3 structs in array. I am trying to avoid dynamic memory allocation. I initialize sensors to 3 to reserve space for them in memory, since there may be at most 3 elements in the array. But I am testing a condition where there will only be 2 elements:

Code:

#include <stdio.h>#include <stdlib.h>
#include <string.h>
typedef struct {
unsigned long long int address;
float current;
unsigned char pressure_units;
} sensor;

[Code]...

The problem is even though there are only 2 sensors out of 3 in the array, sizeof(sensors)/sizeof(sensors[0]) returns 3. I assume because when it allocates memory for 3, it includes that allocated memory even though it really doesn't contain the struct. How can I figure out how many elements were really inserted into array, not just allocated to array?

View 3 Replies View Related

C++ :: Check If Number Belongs To Particular Base Or Not

May 2, 2013

I am making a number base conversion program in c++, suppose that user enters an base 2 number and want to convert that number in base 4. when he enter the number (which he wants to be converted), how can i detect that number is belongs to base 2 number system or not.

For example: if user enter 1001011001 , program should continue and convert that number to base 4. and if user enter 1200101 or 1001012 , program should not convert that number and output that this number is not belongs to base 2 number system.

View 6 Replies View Related

C++ :: Check If A Number Is Odd Or Even And Print It To The Screen

Mar 8, 2013

My objective is to check to see if a number is odd or even and print it to the screen just to make sure its working correctly.

The data file contains:
138
402 2 485
9
43
98 805
58
421
948 7 97
48
67
35
42
948
579 39 12
700 20 500 210
98

I can get the numbers to print fine using:

fstream infile1(argv[1]);
if(!infile1.is_open())
cout << "Could not open file";
else {
char listNum;
while(infile1.get(listNum))
cout << listNum;
}

However, when I check for odd or even numbers it will check each and every number.

printed like this (partial list):
1 is odd 3 is odd 8 is even
9 is odd

But it should print:
138 is even
9 is odd

I tried using getline, but it keeps giving me the errors:
invalid conversion from 'void*' to 'char**'
invalid conversion from 'char' to 'size_t*'
too few arguments to function 'ssize_t getline(char**, size_t*, FILE*)'

Here is the getline code, what am I doing wrong? I have tried switching things around, adding things. Just nothing works.

ifstream infile1(argv[1]);
if(!infile1.is_open())
cout << "Could not open file";
else {
char listNum;
getline(infile1, listNum);
cout << listNum;
}

View 2 Replies View Related

C++ :: Choose A Number To Check If Prime Or Not

Oct 20, 2014

#include "stdafx.h"
#include "iostream"
using namespace std;
int main (){
int x;
int i;
int e;

[Code] ....

is the logic good ? and why the program is looping

View 3 Replies View Related

C# :: Check Number Enter In Textbox And With DLL

Jul 12, 2014

This program with DLL that check number enter in textbox and use RGB for change color

example: if user enter 000 (000:black) changed color automatic textbox to black, and other 111 ....

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;

[Code]....

View 4 Replies View Related

C/C++ :: Check If A Number Has Decimal Place

May 31, 2014

I'm trying to make a program to check if a number has decimal place, for instance: 1.34(yes), 1.0(no), 3.45(yes), 5.0(no).

Code:

#include <stdio.h>
#define LENGTH 4
int main( void ) {
int i;
float a[LENGTH];
for(i=0; i < LENGTH; i++) {
scanf("%f", &a[i]);

[Code] ...

I'm getting this output, why?

Quote

error: invalid operands of types "float" and "int" to binary "operator%"

View 3 Replies View Related

C :: Obtain Check Number And Then Company Information From Datafile

May 13, 2013

I have to obtain a check number from a datafile and then also get company information also from a datafile.

So my first question is about the:

Code:
char outputFilename[]= "out.list"

Is this the name of the output file I'm going to write to? And also the file has to be created before being used...is that line of code creating the file or do i have to create it in notepad?

Code:
FILE *ifp, *ofp;
char *mode = "r";
char outputFilename[] = "out.list";
ifp = fopen("in.list", mode);
if (ifp == NULL) {
fprintf(stderr, "Can't open input file in.list!

[Code] .....

View 7 Replies View Related

C++ :: Program To Check Validation Of Functions

Apr 12, 2013

I'm writing a program to check whether codes from a file are invalid, valid, inactive, or valid and active, but can't get it to work properly. The invalid codes are being found, but the other three are not. I think it may have something to do with my "active" function.

#include <iostream>
#include <fstream>
#include <string>
#include <cctype>
using namespace std;

struct ActiveCodes {
string code;
bool flag;

[Code] ....

View 19 Replies View Related

C++ :: Program To Check The Leap Year

Oct 7, 2013

Check the Leap Year Program In C++:

#include <iostream>
using namespace std;
int main() {
int yr;
cout << "Enter year : ";

[Code] ....

Check the LeaP Year... [URL] ....

View 2 Replies View Related

C++ :: Check The Coding Style Use In A Program?

Apr 30, 2014

Is there any opensource tool which can check the coding style use in a program.

View 2 Replies View Related

C :: Program To Check For Balanced Parentheses Using Vector

Feb 21, 2014

Program is supposed to check for balanced parentheses which are (), {}, [] using a vector First read in the number of lines user wishes to testReturn Yes if balanced, No if unbalanced. Missing conditions to check for unbalanced parentheses Program doesn't catch left parentheses returns YesPairs wrong parentheses together, (} returns Yes, should be No Cases with incorrect output (}, (], ))), }}}, ]]], just a space or nothing entered. how I can correctly catch the cases I've missed

Code:

#include <stdio.h>
#include <stdlib.h>
#include "char_vector.h"
int main( int argc, char * argv []) {
int i, num;
char c;
scanf("%d", &num);
scanf("%c", &c);

[Code]...

View 7 Replies View Related

C++ :: Program To Output A Check With Correct Spacing

Oct 14, 2013

So I have to write a program that outputs a check with correct spacing and everything.

Create a project titled Lab7_Check. Write a program that asks the user the check information and prints the check. The dialog should be as follows:

date: 2/23/2010
name: William Schmidt
amount, dollars: 23
cents: 30
payee: Office Max

your check:

William Schmidt 10/13/2013
pay to: Office Max $23.30
twenty three and 30/100 dollars

You may assume that a person always has the first name and last name (no middle names or initials). The payee name is also always two words. The dollar and cent amount are integers and the amount is always less than 100 dollars. Note that the dollar amount could be zero, in which case, when you spell the dollar amount, it should print "zero". The date is always a single (non-white space separated string). Your date, dollar amount in numbers and the word "dollars" have to vertically align.

This is the code I have so far.

#include <iostream>
#include <string>
using namespace std;
int main(){
string date;
string firstname;
string lastname;

[Code] .....

View 3 Replies View Related

C++ :: How To Check For Data Type When Input Value Into Program

Apr 11, 2013

How would I check for proper data type when someone is to input a value into the program? Ex:

int i;
string a;
cout << "Enter a number: ";
cin >> i;
cout >> "Enter a string: ";
cin >> a;

How would you check to make sure that int i would be an actual number and not a letter like "a"?

View 4 Replies View Related

C/C++ :: Write A Program To Check The Password Strength

Apr 17, 2015

add more code given bellow program that means (( you can input a password and the output checking the password is valid or not and also the password is hard or weak)) the program,s output show....the given password is too strong or strong or weak and also check the password is valid

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved