This forum is in archive mode. You will not be able to post new content.

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - blackboxx

Pages: [1]
1
C - C++ / Re: What is c++ GLUT library used for ?
« on: October 22, 2012, 07:06:16 PM »
In my university, GLUT is taught in a 400-level, Computer Graphics course. Students here are expected to use the application Codeblocks, which contains the appropriate libraries necessary to create applications using GLUT. You should have enough programming experience before trying to learn GLUT, since it is not that far off from the C syntax. I am sure you can use it for gaming graphics, and related things. Before learning it, I think it's necessary to have a decent background of linear algebra. 


This attachment should help you learn more about GLUT:

2
Aw man, I missed that. I think you'll love using class structures, as oppose to the long methods. coolcool lol

3
Maybe you should of posted that in Weekly challenge? Before you do that you should contact the admins :P


Oh, I initially made this assignment for this user, since he needed some practice. I could come up with other things for the weekly challenge though. Thanks.

4

blackboxx's Assignment:


My assignment should show skill, using loops, functions, arrays/pointers, and class struct, to a degree. Knowing me, I like applications, that can calculate specific things, so my assignment will be to make a calculator. This calculator should allow the user to be able to find the sum, difference, product, and quotient of numbers. An easy approach would've been to ask the user to input just two numbers, and operate on those two only. However, as a programmer, you want the user to have flexibility with how they use the program, instead of limitations, so the user will be prompted, how many numbers they want to input, to be operated.


For instance:


1 + 78.4 + 88.44545 + 4435345.545


OR


45.9 * 34.4 * 4345.55


- The user should be able to input how many numbers they want to input into the program, to be added, subtracted, multiplied, divided, or all.


- The user should be prompted with choices: Add, Subtract, Multiply, Divide, All, Exit.


- There should be exception handling in your program, to prevent logical errors, and run-time errors.


- You should use a class structure, or class structures, to make this program, since we want to take an object oriented approach.

5
C - C++ / Re: C++ separate file compilation confusion :/
« on: October 16, 2012, 08:27:37 PM »
No probz.  ;)

6
C - C++ / Re: C++ separate file compilation confusion :/
« on: October 16, 2012, 08:16:15 PM »
Yea, you cannot copy exactly what I inputted, since there are three separate file's code included. For some reason, this forum wouldn't allow me to make three separate boxes for each file's code.


I  included attachments.

7
C - C++ / Re: C++ separate file compilation confusion :/
« on: October 16, 2012, 07:59:05 PM »
First, I would strongly recommend you use Codeblocks, if you are on Windows. It will allow you to create a project, containing multiple .h and .cpp files, much easier.


First, for prots.h, you needed to include #include<iostream> at the top.


Secondly, for your prots.h, you declared two "void" function prototypes, but in your implementation, in functions.cpp, you changed their data types to "int". Changing them to void, pretty much fixed compilation problems. Also, adding "using namespace std;" in functions.cpp, allows you to use "cout" and "cin".  Otherwise, use "std::cout" or "std::cin".


Here is the updated code, which should compile, in their respective files:


main.cpp, prots.h, functions.cpp, respectively.
Code: [Select]

//main.cpp
#include <cstdlib>
 #include <iostream>
 using namespace std;
 #include "prots.h"








 int main(int argc, char *argv[])
 {
 player player1;
 player player2;
 cout<<"Number 1 \n";
 getinfo(player1);
 cout<<"Number 2\n";
 getinfo(player2);
 cout<<"Number 2\n";
 showinfo(player2);


 cout<<"Number 1\n";
 showinfo(player1);












 system("PAUSE");
 return EXIT_SUCCESS;
 }


prots.h

#ifndef PROTS_H_INCLUDED
#define PROTS_H_INCLUDED


#include<iostream>  // Needed to include #include<iostream>


struct player{std::string name; int age;};


void getinfo(player&a);
void showinfo(player&a);


#endif // PROTS_H_INCLUDED


functions.cpp

//fucntions.cpp
 #include "prots.h"


using namespace std;    // To make cout, and cin work.


 void getinfo(player &a){   // Wrong data type
 cout<<"ABOUT PLAYER \n";
 cout<<"Name :\t";
 cin>>a.name;
 cout<<"Age :\t";
 cin>>a.age;}


 void showinfo(player &a){
 cout<<"PLAYER INFORMATION \n";
 cout<<"NAME :\t"<<a.name;
 cout<<"\nAGE :\t"<<a.age;}

8
C - C++ / Re: Help me with my code.
« on: October 16, 2012, 03:31:10 PM »
You should use #include <cstdlib> in order to use "system" actions, like system("PAUSE");, or system("CLS");. It should work if you include that.


On a side note, you may want to create functions for finding the sum, difference, product, and quotient to make your main program source code more neat, and structured.


For example:


Code: [Select]

#include<iostream>


double findSum(double n1, double n2)
{
    double sum = n1 + n2;
    return (sum);
}


int main()
{
    double num1, num2;


    std::cout << "Input 1st number:";
    std::cin >> num1;
    std::cout << std::endl;
    std::cout << "Input 2nd number:";
    std::cin >> num2;
    std::cout << std::endl;


    // Output
    std::cout << num1 << " + " << num2 << " = " << findSum(num1, num2);


    std::cin.ignore();
    return 0;
}

9
C - C++ / Re: Compile error
« on: October 16, 2012, 11:33:27 AM »
You may want to change a few things with your string variables. A string is an array of characters, and you only seem to be using characters. An array of strings is a bit unnecessary, since you are dealing with single characters, for every element. You're trying to compare a user's input of answers, with the correct answers, predefined, so I think "correctAnswers" should be constant, just to ensure it doesn't change for any reason. But yeah, look at a string as an array of characters, I think this should help you look at the code differently.


For instance:


Code: [Select]
std::string sixLetters = "abcdef";
// element 1: "a", element 2: "b", ... , element 6: "f"

Pages: [1]


Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.