hi
i m new to this forum
actually i ve joined this forum coz i m havin problems in c++ i m a student of telecom
will any of u plz help me in writing a code for the following programs:
1.write a program that take 5 digit number input and prints the digits of number separately eg.if i enter 45673 it should give output as
4 5 6 7 3
2. Write a program to work out the time period in year, months and days between two given dates.
3. Write a program to reverse the digits of a positive integer number. For example, if the number 87356 is entered, the number displayed should be 65378 (use a do-while loop).

i ll be thankful to u if u help me
i need codes of program
reply as soon as possible

We don't give codes away.....you must show effort for us to help you. Even just start off and we'll guide you in the right direction. Welcome aboard though.
#1
You could start off by doing a few things:

#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
#include <string>

using namespace std;

int main()
{
	int number,d1,d2,d3,d4;//variables needed for the program


	cout<<"Please enter a number to separate each digit"<<endl;//instructs the user to input the number
	cin>>number;//input a number
{
now in here use the '%' operator to see what each digit is
}
	cout<<" "<<"each digit of the number is "<<d1<<" "<<d2<<" "<<d3<<" "<<d4<<endl;
	return 0;

#2
In your second program, is it simple. Initilaize some variables....throw in a few loops and see what you can come up with.
Heres a head-start:

#include <iostream>
#include <cmath>
#include<cstring>

{
	int month = 0;//initialize a few variables
	int month2 = 0
	int day = 0;
	int day2 = 0;
	int year = 0;
	int year2 = 0;
	numofdays = 0;
	julianDate = 0;

{
Here you can use arrays to some valuable data....number of days in each month....hours per day...ect...
}
cout << "\n Calculates # of days between dates" << endl;//ask the user to enter dates
  cin >>  month >> day >> year;//user enters info
{
in here use a FOR loop to check with month...hint...not all months of th year have the same # of days. You'll also have to make exceptions if a year is a leep year!
}

A few other pointers:
This program will require the julian date formula and also a formula for when a year is a leap year.
#3
For your third assignment..to reverse the digits...as always....create a few variables that you'll need (show a few lines before).
Secondly...create a output statement(to the screen) to ask the user to enter a digit:

cout<<Please enetr a number to get it's reverse<<endl;

Now, you may use some if/else statements (personally prefered) to give you the reverse of the numbers.
Hope this helps, but you need to learn this stuff and try!!

For problems 1 and 3, look at what you can do with integer division and modulus operations ( / and % ). #3 is actually the easier problem, if all you have to do is display the result.

For the problem 2, are the input dates also given as year, month, day? How would you compare two dates manually? One solution is to compute the ordinal day of the year that a date represents, then you can adjust for different years and find the total days between the two dates. Convert that amount back to years, months, days.

Hmm, is it really valid to say that two dates are mm months, dd days apart, when the size of months is variable?

Val

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.