I was trying to do the practice problems but don't understand what the first beginner or first intermediate problem is asking me to do

Write a program which finds the factorial of a number entered by the user. (check for all conditions) (Beginner).

Create a simple Palindrome checker program. The program should allow the user to enter a string and check whether the given string is a palindrome or not. Only digits and alphabets should be considered while checking for palindromes -- any other characters are to be ignored. (Intermediate)

can someone tell me want a Factorial is or Palindrome

Recommended Answers

All 2 Replies

Did you even try to Google any of those?

Hi k59,

Sorry, I understand that google can be used but these are the practice problems on daniweb's C++ forum. So I feel an answer should be forthcoming! -- i.e. they are not homework questions!

So this is what the questions ask and what I think you will learn from doing them. Please feel free to post your attempts for comment! I think MosaicFuneral has just got a little jaded of people asking "can you do my homework for me".

Factorial:

This is a simple mathematical problem to multiply all the number up to the value given e.g. factorial(4) == 24 because 1*2*3*4 = 24, It is normal to write 4! to mean 4 factorial. so the first few are

1! == 1
2! == 2
3! == 6
4! == 24
5! == 120

and so on.

Obviously this can be VERY big very fast. With C++, using an int, you are not going to get past about 35! (I can't remember -- you can find out!!)

So the problem is to write a program to calculate a factorial of a given number (e.g. typed from the keyboard).

The aim of the problem is to (a) teach loops (b) simple functions and for advanced students to teach recursion and for very very advanced students to teach when not to use recursion :) .

If you manage to do the problem (anyway), you will have progressed.
If you come back to the problem a year later, you will see the problem differently, and get a different perspective.

Palindome

A palindome is a string that is symmetrical e.g. icode]abcdcba[/icode].
The problem is to efficiently determine if a given string has this symmetric property. It is an excellent problem, since it shows you how to be accurate in dealing with all types of input, e.g. what about a even length string over a odd length string. It also is 99% likely to involve pointers (or array offsets) and that is a difficult area for many in c++.

Hope this helps. If you get stuck/confused or even if you are successful. Feel free to post for comments.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.