~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

As mentioned earlier, the FIbonnacci sequence is a classic example of recursion.

...which even can be solved with a really simple loop.

Since the langugages in which we program are normally turing complete, there is as such nothing which can only be solved using recursion. A real example of recursion would be the one in which the iterative solution would not be too apparent and even when such a solution is found, would be too complex. Recursive descent parser, like Raye mentioned, Backtracking problems still stand as a good examples.

Graphical representations of some of them using applets here.

mattyd commented: recursivity help- Thanks S.O.S.-- mattyd +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Categorization is for the weak minded people who need a reason to learn a lanaguage. Programming is an art and language are the tools for artists.

Of course if given a problem domain and the requirements, this question would have carried *some* validity but as such it stands its really a pointless question.

You are lucky you didn't ask this question on a newsgroup, otherwise you would have being ripped apart in no time...

Salem commented: More rep++ from Salem :) +6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I guess what I would like to know..., is there a way I could change the value in the string array using the pointer?. Or I will always need to initialize the array with the string?.

Actually there are many ways to change value of a character array using a pointer to it...

// Untested !!!

int main( void )
{
    int i = 0 ;
    // first way -- initialize while declaring
    char arr[BUFSIZ] = { '\0' } ;

    char* ptr_arr = arr ;

    // second way -- use string copy
    strcpy( ptr_arr, "Hello" ) ;
    puts( ptr_arr ) ;

    // Third way -- use fgets( ) or any other function which accepts user input
    puts( "Enter the string: ") ;
    fgets( ptr_arr, BUFSIZ, stdin ) ;
    puts( ptr_arr ) ;

    // And many other ways like looping through the entire array
    // and setting up individual characters
    putchar( '\n' ) ;
    for( i = 0; i < BUFSIZ - 1; ++i )
        ptr_arr[ i ] = '0' ;
    ptr_arr[ i ] = '\0' ;   // add a null terminator at the end
    puts( ptr_arr ) ;


    getchar( ) ;
    return 0 ;
}
Dave Sinkula commented: Thanks for doing my cleanup/followup. I was meaning to get around to it... --Dave +9
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

, about my heart.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Two questions rolled into one ... what is the difference between Virtual Memory and a Page File

You are getting confused -- Paging is a mechanism used to implement the concept of virtual memory. Paging is a mechanism in which the entire virtual memory is divided into pages -- pages which on demand can be pulled in them physical memory as and when required and written to secondary storage when they are no longer needed (process is idle, etc.). A page table is used to maintain the mappings between the pages and frames i.e. for a chunk of data if it resides at a virtual address X then its physical address is Y and vice versa. Hence whenever data is moved out from the Physical memory or brought into it, changes need to be made to the page table.

and how is this different from Linux swap?

The main difference lies in their names. Swapfiles operate by swapping entire processes from system memory into the swapfile. This immediately frees up memory for other applications to use.

In contrast, paging files function by moving "pages" of a program from system memory into the paging file. These pages are 4KB in size. The entire program does not get swapped wholesale into the paging file.

Also, with a whopping 8 gigs of RAM, why are 2 full gigs used up of this virtual memory?

I think both you and Joey and confused as to what "Virtual Memory" actually stands for the physical …

Dortz commented: Noone ever actually explained it to me fully. +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

try using...
fflush(stdin);
after every gets();

Bad, bad really bad. Read this.

Salem commented: More power pills than pacman - Salem +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hello to all programmers out there. Considering the growing request for practice problems by the beginners, we ( Me, Joey, Niek, Aaron..) have decided to start a sticky which will host some common practice problems which would help the beginners in understanding the programming concepts in a better way. (Did I mention 'Practice makes a man perfect' ? ;) )

The practice problems enlisted will have their own difficulty level or the skill level required(beginner to expert). However feel free to jump to any of them if you think you are up for it.

Please don't post "Thank you" posts in this thread since this is meant to be used as a guide for all beginners. Also if you have already developed a solution and want to get it verfied, don't post it here -- create a new thread. Any "Thank you", "Help Me", "Spam" posts will be prompty deleted. I hope you understand this.

Some general guidelines while attempting the problems for beginners or those who have just started programming:

  • The use of all non standard headers and functions is discouraged. Implement the problem with only standard C / C++ functions. A list of standard C / C++ functions and headers can be found here.
  • Don't use system("pause") to pause your program if possible. Use getchar( ) if you are using C and cin.get( ) if you are using C++.
  • The prototype of the entry point of the program i.e. the main function is int main( void ) . …
hammerhead commented: Cool :D +2
tux4life commented: Very good !! +3
The ICE Man commented: Nice :) +0
mide commented: i cant answer any of the questions, i'm a novice +0
scarcella commented: nice, im new to C++. So this i guess could help me out!! :D +3
febiri peter commented: send the format of c++. +0
dchrismoore commented: This is a nice idea, but it reads like thre are supposed to be links to other material and there are no links. +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hehe, looks like I beat you
...again

Grr....:mrgreen:

But I guess it doesn't matter since I already beat you at the "Hardest Game Ever"....:twisted:

John A commented: That's what YOU think! Someday I'm gonna hit 60... -joeprogrammer +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

As far as keeping the count on the number of times the match is found, just declare your variable as static and it should work out to be fine. (The static quantifier helps the variable in maintaining its state, in the scope in which the variable is declared)

What is the part which you don't understand about arrays ? Can you give a short eg on how you plan on using the arrays and what would they be storing ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

No I guess its a pretty good thing...

Congratulations you have got two really good friends on your side. And btw, ofcourse me and Niek will continue this ...:D

PS: Btw whats the story behind your new avatar..

Nick Evan commented: Yes, we will indead :) +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I don't know Mr. Jobe if you already know this but there is a book which presents the solutions to the problems posed in C++ Programming Language, you can get it here.

And if you think the book is too expensive or not worth it you can always download the source code for free from here.

Hope it helped, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Joey really has access to some inside info -- either that or he must have read it on other forums where Miss Narue visits.

Anyways, Congratulations Miss Narue, and I hope the best health of you and your baby.

God Bless you both.

jbennet commented: thats a nice thing to say +4
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Heh, I sure owe you one Mr. Happygeek....:D

BTW just one point away from another Rep Medal (shiny green dot) ;)

John A commented: here's another "shiny medal" :cheesy: -joeprogrammer +4
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A good way to gain some rep power Niek...:D

Maybe even I should try out your way and see how things work for me.....;)

happygeek commented: some niek_e inspired rep :) +10
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I thought all the changes to such critical things were made in the dummy project before touching the live working code...;)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
struct {
  char suit;
  std::string face;
  int value;
} deck[52];

Ravalon, have you enabled all the warnings in your compiler settings (-Wall) since the above flags a warning saying "error: no matching function for call to `random_shuffle(<anonymous struct>[52], <anonymous struct>*)' ". You better name the struct just for standard's sake, its not good to let warnings hang around in your programs.

It is a function call. random_shuffle() is a standard C++ function from the <algorithm> header. It saves you the trouble of writing your own shuffling code.

...with such talk of random_shuffle, I would recommend the people to read this.

namespace Raye {
  template <class T>
  inline void swap( T& a, T& b )
  {
    T temp = a;
    a = b;
    b = temp;
  }

  template <class T>
  inline void random_shuffle( T *first, T *last )
  {
    if ( first != last) {
      for ( T *i = first + 1; i != last; i++ ) {
        T *b = first + rand() % ( i - first + 1 );
         T temp = *i;
        *i = *b;
        *b = temp;
      }
    }
  }
}

I wonder why you wrote the swap subroutine...;)

Ravalon commented: I learned something new! -Raye +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hello there.

Either that, or you have some miniscule amount of RAM in your computer. What's your compiler? It's highly unlikely, but a crappy old compiler has much different limits than a modern one.

Yes, an old compiler imposes a limit on the amount of memory that can be allocated to a single variable, but if that were the senario, the program execution would have halted at the point he has declared the three dimensional array.

I hope you realize that even though he hasn't stored any values initially in his array, the space has been nonetheless allocated to him. I don't think any failed attempt after the allocation is due to the old compiler.

And as far as RAM is concerned, he is allocating 729 * 4 bytes ~ 2.85 KB. I don't think this should be as such a problem...;)

Thank you.

John A commented: Correct you are :). -joeprogrammer +4
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hey Sharky, maybe something like this is what you are looking for.

mattyd commented: always helpful and a good member of Daniweb- Sharky +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Don't figure. It will remove the pointer, but that's no guarantee it'll delete the arrays.

Its actually the reverse, delete will remove or deallocate the data pointed by new and not delete the pointer. Simply put, will send the portion of allocated memory to the free store.

You should use one delete for each new that was executed -- and in reverse order.

It is absolutely guaranteed that the memory which you allocated to an array using new[ ] will be deleted using the delete[ ]. Thats the main difference between delete and delete[ ].

The delete[] operator frees storage allocated for array objects created with new[]. The delete operator frees storage allocated for individual objects created with new.

Many systems will actually clean up after you, but it's bad practice to assume that cleanup will be done. So always delete every allocated buffer.

Yes absolutely, but the cleanup is done only when the application quits, its context destroyed and the stack frame removed. So if your application runs for a long amount of time, the memory leaks will just end up hogging system resources. Even a small amount of memory leak can cause big disasters.

SpS commented: Nice Post ~~ SpS +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I'm sure you eagle -eyed pro's can spot the problem in a New York minute, but I've been straring at this too long!

I don't blame you, since what you encountered is one of the C++ gotchas and not many starters know about it.

What you are trying to do here is to create a function which will befriend all the specializations of the Array class, which I don't think any compiler conforming with the standards will allow you to do.

There are some things which you have to do to get around this...

1. Forward declare the class, along with the templated overloaded function.

template <class T> 
class Array ;
template <class T>
ostream& operator<< ( ostream&, Array<T>& ) ;

2. Place <> after the overloaded operator to let the compiler know that this is a templated funcion you are tryign to code here (syntactic sugar...bleh). Something like:

template <class T> //declare the template and the parameter
class Array       // the class being paramterized
{
    public:
        ....
        friend ostream& operator<< <>(ostream&, Array<T>&);
    private :
        ....
};

For an interesting read look here.

SpS commented: Nice~~SunnyPalSingh +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hmm...I think there is some typo mistakes in the above one posted by Mr. Dave.

int compareChar(char *myArr, char *mySecArr)
{
   int count = 0;
   size_t len = strlen(mySecArr);

   // mySecArr should be myArr
   while ( (mySecArr = strstr(myArr, mySecArr)) != NULL )

   {
      count++;
      // mySecArr should be myArr
      mySecArr += len;
   }
   return count;
}
John A commented: Sharp eyes. :) --joeprogrammer +4
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

what gave you the idea that arrays can not be reallocated? new, malloc, or realloc() can be used to do that.

Hello.

Actual arrays can't be resized, what you are talking about is data pointers being allocated enough memory to be used as arrays.

The important differentiation here being used as arrays and actual arrays.

Thank you.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hmm...here is what I think you should do:

1. Always keep a guard condition while making header files which does away with the problem of recursive inclusion of headers. Something like:

#ifndef TGA_H_
#define TGA_H_

// your header file here

#endif

2. Don't know why but your loop looks fishy:

while ( In == NULL )
    {
        cout << "open failure. Please check the file's location and try again.\n";
        cout << "What is the map file's name? ";
        cin >> sMap;
        
        In.open( sMap.c_str() );
    }

Try removing the loop and ducking out if the fle is not found.

3. Tada..and this I think according to me is the culprit:

while ( tempChar != '/n' ) // loop to find the row and col numbers.

Just to let you know there is no such thing as /n, it must have been a typo mistake since you should write \n if validating against a newline character.

4. Oh yes...don't use system("pause") , getchar( ) achieves the same thing without putting portability at stake....

FireSBurnsmuP commented: thanks a lot, that helps +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hello to all Gamedevelopers out there. Many of your have already wanted to get into game development but came to a stand still due to the lack of resources.

Please don't post Spam or Thank you posts in this thread since this is meant to be used as a guide for all beginners. I hope you understand this.

My first post will deal with starting game development using external libraries and API's since it doesn't make sense to start coding a killer Game Engine or a Physics engine as your first attempt.

1. For a list of free game engines along with their reviews look here

2. As far as 3D modelling tools are considered, if you have big bucks you can go for the professional tool 3ds max or Maya. A free 3d modeller is Blender and has the features which match the professional ones (though its a bit tough to learn it).

3. Level editors are also aplenty out there but sadly they require you to pay for using it. A free one is Deled

4. Good sound libraries are:
Fmod: http://www.fmod.org
OpenAL: www.openal.org

5. Network API's
RakNet: http://www.rakkarsoft.com
Zoidcom: http://www.zoidcom.com

6. Physics Libraries:
Newton Game Dynamics: http://www.newtondynamics.com
Novodex: http://www.novodex.com
ODE: http://ode.org
Tokamak: http://www.tokamakphysics.com

As far as my experience and persoanl …

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Actually too many minor things, but I will point out some to you...

using namespace std;
This adds the standard library of C++ commands

Very crude and almost incorrect defination. Namespaces are basically used to resolve name collisions. You can look here for what it actually is.

This line initializes a function called "main" this is your core function all programs need to have this function.

"Initialize you say" ;)
This stmt will cause many developers to go into spasms.

cout is the command that tells your program to output something

Actually its much more complicated than that...
Better use the word functions than commands.
Using vague words like "something" doesnt cut ice.

and the endl tells the program to end a line you can use "\n" to get the same effect.

endl actually causes the effect of using '\n' along with "flushing the output buffer.
Therefore

endl => putchar( '\n' ) + fflush( stdout )

And many more...

Now to the main point..it would be better if instead of correcting the mistakes, you just start learning the itsy bitsy details of the language and then write tutorials. Instead of asking us what the problems are and then correcting them, why not rise to a level where you would be in no need of counsellling as such.

Think of it this way..by writing wrong things you are actually "misguiding" newbies that come to your site and those …

John A commented: I like this post. --joeprogrammer +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Keep tab or print out the array after each iteration to give yourself a better understanding of what exactly is going on.

BTW your first swap function doesnt do anything, I'll leave it to you to figure it out.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Here I have 1.3 K posts and all they do with me is give me this:

Banned ;)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You cant as such check for such conditions in case of a simple sort like bubble sort.

Take for eg. this array.
1 2 3 4 5 6 8 7

During the first seven passes no swap is performed since the next number is always greater than the current but a final swap is done in the last pass to sort the array. You cant as such terminate a bubble sort based on the flag that swap is performed or not.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I like the fomat of tutorials of this site, maybe this should help as a guideline for you.

Also just wanted to let you know that your site takes a bit too long to load. Maybe its jsut my computer or something but just wanted to let you know ....

Hope it helped, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I have read this somewhere in the context of Processor architecture. The compiler tries to align the data and the pointers along the boundaries i.e. in multiples of 4.

So the addresses are given along the lines of multiples of 4.

Not very sure about it but atleast this should give you a starting point.

JoBe commented: Great help, nice person. +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

i dont like the reuputation system as noone ever gives you any - ive got like 600 odd posts and basically no reputation
have you seen the msn q&a beta dani?
i think a "best answer" type system woule be good

It just depends on the forum, and I think Daniweb has got a lot of evolving to do in terms of reputation.
There are many forums where reputation is rampant and in full swing. What I mean by this ? Well its like if I am a moderator of C++ forum or you are a C++ forum frequenter and if you find a post of Javascript nice or informative or feel that the post has very good content, you add the reputation to that person.

The reason reputation works there is because the people who have added reputation, their name appears at the bottom of the post, no need to go to the control panel. Thats the thing people like the post about it since it shows to you who has added rep to you and even you keep that in mind the next time you encounter that persons post.

The name here is not specfied since Miss Dani thinks that giving out name will cause increased tension among the members. But I dont
think there is any kind of tension among people of forums where there is open reputation system.

And as far as adding reputation is concerned I add REP …

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

FLCL
Naruto
Samurai Champloo
Innocent Venus
Black Lagoon
Death Note
Ouran High School Host club
Air Gear
D Gray Man
Black Blood brothers

and many more.... :D

arjunsasidharan commented: nice collection of animes bro!!.. i thought you like getbackers? +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Naa you aint defining the default constructor, you are just declaring it in Complex.h but its defination doesnt occur in Complex.cpp, thats the whole root of the problem.

Implement one in complex.cpp and all should work out fine.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
  • You get a hologram of yourself :mrgreen:
  • I put in a pirated mix-CD of Iron Maiden's best 20 songs

Hey buddy, stop using loud colors in your post. All your previous posts are also colored. Its not like it draws more attention they just end up hurting our eyes. We do get and pay attention to what is written in normal way.

Please refrain from using colors.

mattyd commented: he is correct in this +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Okay buddy, what exactly your intension is ? You have been recommended books in the prevoius posts by Mr. Dragon and Mr. Joe. Refer the previous posts for answer to your question.

I'll tell you a cheap way of learning C++. Read the plethora of tutorials available on the net. Maybe then you will get a hang of things and would be in a condition to decide which books are good for you on your own.

So for the time being:
> Grab a free compiler Dev C++
> Google some "beginner C++ tutorials"
> Get started.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hmm anything for a good friend...

Done and done. It would be better if you pasted your request in your signature, that way more ppl will vote for that.

PS: BTW who is the girl Lauren ;)

'Stein commented: Thanks again :) -'Stein +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I am waiting for someone to give me one so that I can see how much is subtracted from my rep points.

Would you mind if it were me !!!:mrgreen:

Anyways thanks a lot Wolfie for clearing my doubts and yeah you said it right.I completely agree with you, as long as i am doing it right i need not fear anyone. Hats off to you.

'Stein commented: Looking to override that red dot. ;) -'Stein +3
arjunsasidharan commented: My turn :) +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I dont know how to put this but Miss Dani i would please request you to place a moderator for this button or anything related to bad posts or atleast come up with a good idea to stop someone misusing this button.

Looks like someone out there, just to take out his personal spite on me has marked the reply posted by me on this thread as "bad post".
http://www.daniweb.com/techtalkforums/post258739.html#post258739

with the demented comment

it's not neccesary to comment on everything. above post eas sufficient

No crap, so spam, no flaming just a good piece of info !!!!

In the name of god, i would request Miss Dani to personally visit the thread and judge for yourself what was wrong with my reply.


Only because someone snuck in to reply when i was writign down my own one. Just for a difference of 5 MINS, i tell you 5 MINS someone thinks i am doing this as a formality.

Hope you please tackle this matter personally least i should lose my faith in the functioning of this forum which i have always loved.
The response of my post will decide what has become of my dedication to this forum.

Requesting everyone out there to judge for urself if i was really wrong or not.

The Dude commented: Its ok my friend........Heres some GOOD rep to make up for it!!! (1 red dot wont hurt ya) +1
joshSCH commented: hahaha.. Aww.. poor, naive Sanjay.. :D +13
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If you have a dilemma post the real question to your dilemma instead of being vague all over. And whats up with this kind of attitude? Maintain it and you would be sure to make a lot many friends here.

And as far as pushing on to the next thing is concerned, this is a public forum where everyone is free to post whatever they like unless the content is filtered by the moderator. So if you dont want to get disturbed with these dilemmas move on to a Pay Site for homework help or learn to live with this.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Try out something like:

#ifndef SAVINGSACCOUNT1_H
#define SAVINGSACCOUNT1_H

class SavingsAccount 
{
private:
    float annualInterestRate;
    float savingsBalance;
    
public:
    SavingsAccount()
    {
      annualInterestRate = 0;
      savingsBalance= 0;
    }
    
    SavingsAccount (float my_interest_rate, float my_savings_balance)
    {
        annualInterestRate = my_interest_rate ;
        savingsBalance = my_savings_balance ; 
    }
    
    float calculateMonthlyInterest()
    {
        float subtotal = 0;
        float monthlyint = 0;
        subtotal = savingsBalance * annualInterestRate;
        monthlyint = subtotal / 12;
        savingsBalance = monthlyint + savingsBalance;
        return savingsBalance;
    }
    
    void setInterestRate (float my_interest_rate)
    {
        annualInterestRate = my_interest_rate ;
    }
    void printSavingsBalance()
    {
        cout << "Your balance is: $" << savingsBalance << endl;
    }
};
#endif
#include <iostream> 
#include "SavingsAccount.h"
using namespace std;

int main()
{
    SavingsAccount saver1 (1, 2) ;        //instantiate saver1;
    SavingsAccount saver2 (2, 3) ;        //instantiate saver2;

    saver1.printSavingsBalance();
    cout << "Interest of Month #1" << saver1.calculateMonthlyInterest() << endl;
    saver1.setInterestRate (4);
    cout << "Interest of Month #2" << saver1.calculateMonthlyInterest() << endl;
    return 0;
}

Hope it helped, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yeah post your effort here and then maybe we would be able to help you out, just asking for code here would not fetch much help.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If you want the program to recover the files which you deleted by mistake then you are posting in the wrong forum but still can take a look here:

http://www.pcworld.com/downloads/file/fid,23069-order,1-page,1-c,utilities/description.html
http://www.diskinternals.com/

Hope it helped, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It seems odd that he would state preorder as being reverse post order. Why not just as for a preorder traversal algo. But than nothing surprises me these days so you could be right?

Yes its possible I may be wrong but lookign from his code and the limited senario he has painted in front of me, i thought maybe he didnt know about preorder and needed some direction. But then again you cant know the mind of these young developers, maybe he wouldb be the first one to write a technical paper on Reverse Postorder :mrgreen:

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

.

class PAIR
 
{private:
 int a;
 int b;
 
public:
 
 void print();
 PAIR();
 PAIR(int);
 PAIR(int,int);
 ~PAIR();

 void swap();
 int diff();
 int big();
 int area();
};

int main()
{
PAIR c, d(2), e(12,13);

int ans;
c.print();
d.print();
e.print();


d.swap();
d.print();
e.swap();
e.print();

ans = c.diff();
cout << "\nThe answer to c.diff() is  " << ans << endl;

int big = e.big () ;
cout << "\nThe larger number of e.big() is  " << big << endl << endl;

return 0;
}

PAIR::PAIR() 
{
a = 2;
b = 3;
}

void PAIR::print()
{cout << a << " " << b << endl;}

PAIR:: ~PAIR()
{
  cout << "Display Destructor Message" << endl;
}

PAIR::PAIR(int p1)
{a=p1;
b=p1;}

PAIR::PAIR(int p1,int p2)
{
a=p1;
b=p2;
}

void PAIR::swap()
{
 int c;
 c=a;
 a=b;
 b=c;
}

int PAIR::diff()
{
    return b - a;
}

int PAIR::big()
{
    if (a > b)
    {
        return a;
    }
    else 
    {
        return b;
    }
} // this was missing

int PAIR::area()
    { 
                int z;
    z=(a*b);
        
    {
    return z;
    }
}
    
// } 
// this is extra brace

The things marked in red by me are the culprits. WHy dont u format the code properly so that typographic errors will be minimised. Do you write your code in Notepad. If so grab your self a syntax highlighter code editor which makes automatically proper indentations like Code::BLocks or Dev Bloodshed.

The links for the above IDE can be found at teh top of this forum in the thread named "Starting …

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I think you are getting the formulas for deviation and variace wrong.

See this code for reference;

#include <iostream>
#include<iomanip>
#include <cmath>
using namespace std;

int main()
{
    float deviation, var ;
    char choice;
    int total_numbers  = 0 ;
    const int arraysize=20;
    int num[arraysize];
    do
    {
        cout<<"I will give you the Sum,Mean,Var & the Std Dev of any series of numbers?Y/N:"<<endl;
        cin>>choice;
        if(choice =='Y'||choice =='y')
        {
            cout<<"How many numbers will you enter? (up to 20)?";
            cin >> total_numbers ;  // this is correct way of accpeting single number
            for (int j=0; j < total_numbers; j++)
            {
                cout<<"Enter Number"<<j+1<<":"; cin>> num[j];
            }
            cout << " You have entered the following:"<<endl;
            for ( int j = 0;  j < total_numbers; j++)
            {
                cout << num[j]<<" ";
            }

            int sum=0;
            for (int j=0; j <  total_numbers; j++)
                sum+= num[j];
            cout<<"\nThe Sum is "<<sum<<endl;
            float mean= (sum/ total_numbers);
            cout << showpoint << fixed << setprecision (2);
            cout<<"The Mean is "<<mean<<endl;

            if (total_numbers > 1)
            {
                for (int i = 0; i < total_numbers; ++i )
                {
                    var += ((num [i] - mean) * (num [i] - mean)) ;
                }
                var /= (total_numbers - 1) ;
                deviation =sqrt(var);
            }

            else
            {
                var = 0.0 ;
                deviation = 0.0 ;
            }
            cout << showpoint << fixed << setprecision (2);
            cout<<"The Varience is " <<var<<endl;
            cout << showpoint << fixed << setprecision (2);
            cout<<"The Standard deviation is "<<deviation<<endl;
        }
    }
    while(choice!='N'&& choice!='n');
    return 0;

}

Maybe for the formula you should look here;

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
#include <iostream>
#include<iomanip>
#include <cmath>
usingnamespace std;
int main()
{

    char choice;
    int total_numbers = 0;
    const int arraysize = 20;
    int num[arraysize];
    do {

    cout << "I will give you the Sum,Mean,Var & the Std Dev of any series of numbers?Y/N:" << endl;
    cin >> choice;
    if (choice == 'Y' || choice == 'y') {

        cout << "How many numbers will you enter? (up to 20)?";
// cin>>num[arraysize];  this is wrong it means entering value in 20th element
        cin >> total_numbers;   // this is correct way of accpeting single number
        for (int j = 0; j < total_numbers; j++) {
        cout << "Enter Number" << j + 1 << ":";
        cin >> num[j];
        }

        cout << " You have entered the following:" << endl;
        for (j = 0; j < total_numbers; j++) {
        cout << num[j] << " ";
        }
        int sum = 0;
        for (j = 0; j < total_numbers; j++)
        sum += num[j];
        cout << "nThe Sum is " << sum << endl;
        float mean = (sum / total_numbers);
        cout << showpoint << fixed << setprecision(2);
        cout << "The Mean is " << mean << endl;
        float var = ((num[0] - mean) * pow(num[0] - mean, 2) + (num[1] - mean) * pow(num[1] - mean, 2) + +(num[2] - mean) * pow(num[2] - mean, 2)) / (num[arraysize - 1]);
        cout << showpoint << fixed << setprecision(2);
        cout << "The Varience is " << var << endl;
        float sqrtvar = sqrt(var);
        cout << showpoint << fixed << …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Since i dont know a lot about all this i cant say anything definate but here are some of the links realted to CURSORS and Oracle and mysql.

http://www.sqlapi.com/Examples/refcursors.cpp
http://dev.mysql.com/doc/refman/5.1/en/c-api-function-overview.html

And also you will have to read the links posted by me in the previous post to get a better understanding since not many people have attempted this thing and you are very much on your own.

Best of luck, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Please explain the problem clearly so that we can help you out. Post your entire code along with the problems you are encountering.. whether it is compile time error or run time error or the program is not working as expectd and so on. Maybe then we would be able to help you out.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

What have you attempted till now, post it here so that we can set your logic right and make you understand things more clearly.