Jason Giggs 1

Dammit, still single

Jason Giggs 1

More is less

Jason Giggs 1

73 571 235 472 239 066 586 495 598 010 130 648 530 944

Jason Giggs 1

wanna go out sometime?

Jason Giggs 1

That was cool. But you know what, it would be super cool if u explain the code too, because i have a doubt that even you can understand that.

murtazamzk commented: doubting +0

Jason Giggs 1

[QUOTE]Turbo C is a dog that's had its day.
[/QUOTE]
does that mean i should just concentrate on programs in Visual C++, or just C++ for instance?

Jason Giggs 1

[B]Try this, the minimalist![/B]

[CODE]#include
using namespace std ;

void main()
{
int response;
int choose;
int num1, num2 ;
do
{
system ("cls") ;
cout << "Enter Two Numbers: " << endl ;
cin >> num1 >> num2 ;
cout << "Do you want to: " << endl;
cout << "1. Add." << endl;
cout << "2. Subtract." << endl;
cout << "3, Multiply." << endl;
cout << "4. Divide." << endl;
cout << "Specify Operation: " ;
cin >> choose;

switch(choose)
{
case 1: cout << num1 + num2 << endl ; break ;
case 2: cout << num1 - num2 << endl ; break ;
case 3: cout << num1 * num2 << endl ; break ;
case 4: cout << num1 / num2 << endl ; break ;
default: cout << "Invalid Operation" << endl ;
}
cout << "Press 1 To Continue, 0 to Exit: " ;
cin >> response ;
}
while ( response ) ;

system ("pause") ;

}[/CODE]

Jason Giggs 1

[QUOTE=WaltP;1419149]And your question about this poor code is... what?[/QUOTE]
hi...why is the code poor? i mean, i didn't even know we could shutdown the pc using c.
can u please tell me a (better) way? Thanks

Jason Giggs 1

0111010001101000011010010111001100100000011010010111001100100000011000010111011
1011101110111011101110111011101110110011001100110011001100110011001110101011101
0101110101011011010110110101101101001000010010000100100001

Jason Giggs 1

do you want to print the values stored in array?
u can use a loop like
[CODE]
for( int i = 0; i < 20; i++ )
{
cout << "Location: " << i << " and Value:" << array[i] ;
}
[/CODE]

Jason Giggs 1

Cool
Welcome!

Jason Giggs 1

Please mark the threads solved if you're finished with the problem.
Thanks

Jason Giggs 1

[QUOTE=flasp;1409886]ty very much...[/QUOTE]
Please mark the threads solved when you're finished with the problem.
Thanks

Jason Giggs 1

Hey Al, welcome to Daniweb. I'm new here too any already started learning.
cheers

Jason Giggs 1

The program converts number of hours into days.
after this, try to code that inputs number of minutes and converts in x days y hours & z minutes.
then u can easily work with seconds.
[CODE]
/*

  • Input: Number of Hours 'H'
  • Output: 'H' hours = 'X' Days and 'Y' Hours
    */
    include

    using namespace std ;

void main()
{
int days, hours ;
int long inputHours ;
cout << "Enter Number Of Hours: " ;
cin >> inputHours ;
days = inputHours / 24 ; //Quotient(Days)
hours = inputHours % 24 ; //Remainder(Hours)
cout << days << "Days and " << hours << "Hours" << endl ;
system ("pause");
}
[/CODE]

flasp commented: very helpfull +1

Jason Giggs 1 Junior Poster in Training

When we define an array, we have to declare its size before the program can be compiled. How can we specify it's size, say, by inputting a value from the user.
I know a way with pointers; any other way?

Jason Giggs 1

Don't tell me, tell the poster the right way .

Jason Giggs 1

[QUOTE]Lol ok guys, I try to fix it tonight .[/QUOTE]
That' Better

Jason Giggs 1

You can use a loop to make a Fibonacci Series.
Its like: 1 1 2 3 5 8 13 21 etc. i.e. next value in series is sum of previous two values.
You may input the number of values the program should print from the user.

Jason Giggs 1

Just google it.

Jason Giggs 1

You should have followed alexchen's code.
Try to keep the code as simple as possible, using fewer variables and cout.

[CODE]

include

using namespace std ;

void main()
{
int response;
int choose;
int num1, num2 ;
do
{
system ("cls") ;
cout << "Enter Two Numbers: " << endl ;
cin >> num1 >> num2 ;
cout << "Do you want to: " << endl;
cout << "1. Add." << endl;
cout << "2. Subtract." << endl;
cout << "3, Multiply." << endl;
cout << "4. Divide." << endl;
cout << "Specify Operation: " ;
cin >> choose;

switch(choose)
{
case 1: cout << num1 + num2 << endl ; break ;
case 2: cout << num1 - num2 << endl ; break ;
case 3: cout << num1 * num2 << endl ; break ;
case 4: cout << num1 / num2 << endl ; break ;
default: cout << "Invalid Operation" << endl ;
}
cout << "Press 1 To Continue, 0 to Exit: " ;
cin >> response ;
}
while ( response ) ;

system ("pause") ;

}
[/CODE]
I think we are done here, better close the thread.

Jason Giggs 1

[QUOTE=flasp;1409547]Done that, and doesnt come up with correct result.. I hope someone can help me with making the code?[/QUOTE]
I have the code but won't post it unless you show what you tried.
Come on, just give it a shot.

Jason Giggs 1

[QUOTE=xikkub;1408726]Following standard programming conventions, it's undesirable to use global variables where locals will do. Use less output and text formatting. Remove unnecessary cout lines and simplify your code before adding final touches. If you simplify the code and learn how to [U]pass data to a function[/U], you can make your work much easier.

Also, Jason, declaring a character array of 10 is NOT a good idea in this case since the day name length can vary. If anything, I'd use a dynamic character array.[/QUOTE]
I just wanted to demonstrate use of array, size needn't be fixed. I was giving an idea how cout can be reduced.
also, thanks for the fact about the global variables, i'll keep that in mind.

Jason Giggs 1

Use a loop, compare each character with space and increment a variable "temp_count" each time a character other than space is encountered. when space is met, compare "temp_count" with another variable "count". if temp_count is greater than count, assign count = temp_count and reset temp to zero to check other words. In end, count will have the value of the length of the longest word.
This should be enough.
A word of advice, try coding on your own. Its now or never; you gotta start working.

Jason Giggs 1 Junior Poster in Training

Hey.. Can anyone suggest me must do projects in c++ so that i can become used to it a develop a little confidence.
Small games, apps would be appreciated.

Jason Giggs 1

Use push() and pop() operations to insert and delete elements in stack.
once you use them, u will be able to print elements of stack.

Jason Giggs 1

Try generalising the program using global variables. instead of using so many cout statements printing the same thing, use one cout and the variables(which will have different values acc to time and day). use a func to calc the values of variables.
EX

[CODE]char day[10];
switch(chday)
{
case 'M':
day = "Monday";
break;
case 'U':
day = "tuesday"
cout<<"\n\n";
break;
case 'W':
day = "wednesday"
break;

    default: cout<<"Error";

}
cout << "The Call Was Made On " << day << endl ;[/CODE]

Jason Giggs 1

a

Jason Giggs 1

[QUOTE=jonsca;1408000]Rather than do that, guide the poster to the right answer without any of this bug squashing.

And your reason is? In reality, you can do it without either by using the characters in the comparison (e.g., c < '1'), but I don't want to steal all the fun.[/QUOTE]

Thank you for guidance..that was my first post. ill work on that and be better next time.

Jason Giggs 1 Junior Poster in Training

hello people...Im new in Daniweb. pursuing bachelors in IT and looking forward to learn a lot from these forums. Gotta be the best to beat the rest.