~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int
main (int argc, char *argv[])
{
  /* Simple "srand()" seed: just use "time()" */
  unsigned int iseed = (unsigned int)time(NULL);
  srand (iseed);

  /* Now generate 5 pseudo-random numbers */
  int i;
  for (i=0; i<5; i++)
  {
    printf ("rand[%d]= %u\n",
      i, rand ());
  }
  return 0;

}

Also Maybe the foll:
random number generate and outpt to file
Random number detailed theory

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

I can do everything and see everything, atleast in the code snippets section.

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

What condition should occur if the user enters 'X' without filling the entire 512 element char array ? What if he enters the third character as 'X' then what should happen, what should the remaining array contain ?

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

Any leads you have got so far, post your code or your algorithm and we will help you out. Posting out what you want to do is no good to us in helping you.

PS: If you want to write random data, use the normal random function which will generate random numbers between 1 and 128. Cast those numbers to "char" data type and write them to your file. This way you will get random chars in your data file.

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

Hi cscgal ! Thanx for your immediate response ! I don't find any other active persons apart from you, why is this so ?

This is because she is the site owner and admin and all the things related to site under are her control. So if you face a problem with the site she is the only one who can find the cause and fix it, not we.
Hope that answers your question.

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

The same is happening with me. Even i cant seem to find the "Contribute a snippet" button anywhere on my screen. Some PHP script error or what ?

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

Hmm.. looks like you really new to programming.

"main()" as you say is the entry point for the program you write. Syntactically and technically you cant write anything outside main except macros, function definations and declarations, and global variables.

So if you want to write "cin" outside main create your own function and then write cin anywhere in that function you want.

By the way, what are you trying to achieve? IF you are a complete newcomer to prog then try out the sticky or thread "Starting C" which will help you out in getting some programming concpets cleared. Also look at these sites.

http://www.cprogramming.com/tutorial/lesson1.html
http://www.cplusplus.com/doc/tutorial/

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

see sizeof() operator -- but the size of a pointer is always the same on 32-bit compilers.

Hm.. Mr. Dragon, i think you are confusing it with something else. The OP wants the size of the "activation record" and not the variable.

For eg. when the program control enters the function, the whole function is pushed in stack by allocating it a stack frame, and the OP wants to know how to find the amount of space consumed by that procedure in the stack.

@Boule
I dont know why you want to find the "size" of activation record, coz that thing is pretty much transparent even to a C programmer and not brought into consideration unless you go in the Assembly lang or Operating system theory depths.
But just for some knowledge, see HERE

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

Maybe some changes incorporated would do the job...
Try to understand the changes made and learn something from the differences in what you had written prev and this code...

#include <iostream>
#include <cstring>
using namespace std;
const double PI = 3.14 ;
void getData(double& length, double& width, double& price);
void getData(double& diameter, double& price);
double computeUnitCost(double diameter, double price);
double computeUnitCost(double length, double width, double price);
int main()
{
        char pizzaType = '\0';
        bool okay = true;
        double price = 0.0 ;
        do {
        cout << "R => round pizza\tS => square pizza" << endl << endl1;
        cout << "Please enter in the type of pizza: " ;
        cin >> pizzaType;
        pizzaType = tolower( pizzaType ) ;
        cin.clear() ;
        cin.ignore(numeric_limits<streamsize>::max() , '\n');
        okay = (pizzaType == 'r' || pizzaType == 's');
        if( !okay )
            cout << "\nYou entered an invalid pizza type!" << endl;
        }
        while(!okay);
        if (pizzaType == 'r')
        {
        double diameter = 0 ;
        getData(diameter, price);
        cout << "The price per square inch for this pizza is " << computeUnitCost(diameter, price) << endl;
        }
        else
        {
        double length = 0, width = 0 ;
        getData(length, width, price);
        cout << "The price per square inch for this pizza is " << computeUnitCost(length, width, price) << endl;
        }
        cin.get( ) ;
        return 0 ;
}
void getData(double& length, double& width, double& price)
{
    cout << "Enter in the length of the pizza: " ;
    cin >> length;
    cout << "Enter in the width of the pizza: " ; …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

write your own

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

Using &quot;scanf&quot; to read character input is a recepie for disaster, however small the purpose maybe. Post your entire code and I will show you an alternative. PS: ALso declare your array as char sequence[ BUFSIZ ] = {\'0'};

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

Have you written the entire code, then it would be better if you post it rather than leave us guessing.

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

Why dont you declare each and every variable as double, that way you can do away with the cast. Also initialize the var at declaration to avoid confusion and using the values before they are defined.

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

Various conditions can exist depending on the value of check, you havent checked them all. For theory of quadratic equations check here: http://mathworld.wolfram.com/QuadraticEquation.html http://en.wikipedia.org/wiki/Quadratic_equation Also if you taking about the precedence when writing down complex and long statements as in case of quadratic eq. solution, use parantheses instead on relying on your knowledge of precedence, that way you would be safe. If this is not the sol. then again repost with a better explanaiton of what you exactly need giving expamples, and also post your entire code.

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

Its also a good practice to make your destructor virtual, and in that way you can be sure that when you start building hierarchies, you dont start wondering where all the memory leaks a coming from (child class object is not automatically destroyed if you dont make destructor virtual).

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

That is because your &quot;getData()&quot; returns void but you are expecting it to return a value by putting a L value at the LHS of the function. You are trying to assign data to the variable by means of a function which actually doesnt return anything. That is because your &quot;getData()&quot; returns void but you are expecting it to return a value by putting a L value at the LHS of the function. You are trying to assign data to the variable by means of a function which actually doesnt return anything.

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

Of course you are welcome here. Enjoy your stay buddy.

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

Post what have you got till now. I dont properly undestand your question, but if you looking for the explanation for how to convert character to code you can look at http://en.wikipedia.org/wiki/Huffman_coding

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

you damned kid

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

Please localize the errors or the problem areas so that we can help you out. Just dumping this big code is a bit daunting to read. Tell us which of your functions are not functioning properly and post only those. Eg. is the insertion going on properly, is there problem appearing in append_file etc..

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

Dont talk in riddles, post the entire code and we will help you out.

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

Okay still getting errors, and I don't know if what I have is actually going to do what I need it to do, but here goes:

using namespace std; // u wasnt there
 
char pizzaType; // dont make this global, put it in main
void getData(int& length, int& width, int& price); // changed to pass by reference
void getData(int& diameter, int& price);
double computeUnitCost( int diameter, int price);
double computeUnitCost( int length, int width, int price);
 
int main()
{
        bool okay = true;
        do {
        cout << "Please enter in the type of pizza: " << endl;
        cout << "r - a round pizza" << endl;
        cout << "s - a square pizza" << endl;
        cin >> pizzaType;
 
        cin.ignore(80, '\n');
 
        okay = (pizzaType == 'r' || pizzaType == 's');
 
            cout << "\nYou entered an invalid pizza type!" << endl;
        }while(!okay);
        if (pizzaType == 'r')
 
       // getData(int&, int&); The most incorrect way of calling functions
        cout << "The price per square inch for this pizza is " << roundPrice << endl;
    //return 0;
        if (pizzaType == 's')
 
         squarePrice = getData();
 
// roundprice and squareprice are not declared
        cout << "The price per square inch for this pizza is " << squarePrice << endl;
 
// price computation functions never called.
}
 
void getData(int& length, int& width, int& price)
    {
 
        cout << "Enter in the length of the pizza: " << endl;
        cin >> length;
        cout << "Enter in the width of the pizza: " << endl;
        cin >> width;
        cout << "Enter …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hmm got it. Anyways thanks.

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

ios646.h is apparently available in the C99 C standards. But I don't know how many compilers have implement those new C standards yet.

I use Code::Blocks IDE which comes packed with the GCC Mingw compiler and the C File created in it does not recognize the C++ keywords.

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

Again, it depends on which country you live in. Not all keyboards have a & key!!!! Actually &quot;and&quot; looks a lot more readable than &quot;&&&quot;. Dev-C++ uses a much more international open source GNU compiler.

As expected from a Python proponent :D But seriously, i agree with Mr. Iamthwee, its would be better NOT to use such keywords which are fully integrated in C++ standards but require the inclusion of a seperate header file #include <iso646.h> . So if you want your C++ code to be compatible with C standards, better stick to the && operator.

C90 does not have these built-in keywords, but it does provide a standard header file that contains definitions for the same words as macros, behaving almost like built-in keywords. The recommended practice for code intended to be compiled as both C and C++ is to use &quot;and&quot; identifiers only for special meanings, and only after including the header <iso646.h> .

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

Please dont bump old threads, post your problem in a new thread. Thread closed.

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

Oh sorry looks like i am growing senile...
Here is the correct link

http://math.nist.gov/lapack++/

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

Maybe HERE

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

Assuming you want to learn what's wrong with your code and not just let someone else do your homework for you

Heh, just saw that he had made an effort so he deserved a helping hand. Hmm.. will have to keep giving out solutions under control otherwise I will get a load of PM's. Thanks for the "gentle" nudge.

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

So listen up, noobs! Post enough information that we don't have to guess at what you need to know. You need to tell us! That way us folks that are trying to help you pass your classes won't get into arguments like this one!
:p ;)

lol.. :D I agree with you on that one, old buddies fighting over beginners is indeed not a good sight :)

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

Some good newbie tuts HERE.

Also try adding getchar() before return 0 for the screen to wait for you to see the results.

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

How about a bit of modifications:

int main()
{
    long number = 0, total = 0, subtotal = 0 ;
    bool zero_occured = false ;

    while ( true )
    {
        std:: cout << "\nEnter an integer to add: ";
        cin>> number;
        cin.ignore (1000,10);

        if( number == 0 )
        {
            if( zero_occured == false )
            {
                zero_occured = true ;
                std::cout << "\nSubtotal: " << subtotal ;
                subtotal = 0 ;
            }
            else
            {
                std::cout << "\nTotal: " << total ;
                break ;
            }
        }
        else
        {
            subtotal += number ;
            total += number ;
        }
    }
    return 0;
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Post what you have done till now and we will help you out.

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

Looks like you have a major problem with your syntax concepts.

1. There should be no semicolon after the conditional stmts
if ( ) ; is wrong

2. You need to nest your braces properly.

if (something) && (something eles) .. is wrong

It should be like

if ( (something) && (something eles) )
int main()
{
//intitialize variables
float test1,test2,assign1,assign2,avg_test,avg_assign;
const float pass_grade=0.50;

//get user input
printf("Please enter two test scores");
scanf_s("%f,%f",&test1,&test2);
printf("Please Enter two assignment scores\n");
scanf_s("%f,%f", &assign1,&assign2);

//check for valid data
    while ( (test1<0 ||test1>100)&& (test2<0||test2>100)&& (assign1<0||assign1>100)&&(assign2<0||assign2>100))
    {
        printf("Error your score must be between 0 and 100\n");
        printf("Please Enter two test scores\n");
        scanf_s("%f,%f", &test1,&test2);
        printf("Please Enter two assignment scores\n");
        scanf_s("%f,%f", &assign1,&assign2);

    }


        avg_test=test1+test2/2;
        avg_assign=assign1+assign2/2;


        if  ((avg_test>=avg_assign)&& (avg_test>=pass_grade))
        {
            printf ("You have passed because of your test grade :%.2f",avg_test);
        }

        else if((avg_assign>=avg_test) &&(avg_assign>=pass_grade))
          {

           printf ("You have passed because of your assignment grade :%.2f",avg_assign);

           }
        else if (avg_test>avg_assign)
        {
            printf ("Your test grade was not high enough you have failed %.2f",avg_test);
        }
        else
        {
            printf ("Your assignment grade was not high enough you have failed %.2f",avg_assign);
        }



    return 0;
        }
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

There's really no need to be horrid. :confused:

Heh, dont mind him, it was just a fatherly nudge..:D
After all he is the MOD you know

Anyways please post the code which you have written and we will help you out.

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

How about something simple like:

for( int i = 0; i < roomNumber; ++i )
{
   // do what you want here
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

*egad*
Yes or no would have sufficed the purpose, you dont need to give me an heart attack you know, after all i am your "Mod friend" hehe.

*sigh* Ah this sure is a sad little world *sigh*

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

Think about it logically, where do you need to keep the loop. It should be obvio after the variables required throughout the prog have been entered by the user. So the loop should logically be placed before the block when you start accepting theroom specs from the user. Hence place the loop after you ask the number of rooms and the tile size from the user.

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

Bah... I give up..
I am sure i could have got the answer, it just doest click.

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

I dont konw a lot about web development, but is this what you are lookign for:
http://xstandard.com/download.asp?product=lite

Or try to surf this page and see what you can find:
HERE

Hope it helped, and if not dont flame me please like the rest :D

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

Just one thing you should know -- There are people, there are good people, there are bad people, its the way how world is made of.

And no its not the general beat of the community, see the forums for other langs and you would know. Some people like to humiliate others and gain a superior feeling...
Please dont be angry or downtrodden. Just keep posting ignoring the "freaks" and if anything get out of hand just click the FLAG BAD POST link at the top of each post so that we know when something wrong is going on.

Keep rockin...dude...

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

Cool. And I think you're right - it does look more bloggy.

Hmm... maybe i should start taking Web design classes from Miss Dani, i hope you wont charge your moderator buddy, would you? :D

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

Do you know how to add to this current time seconds, minutes, days?Also I need to get two dates and make some actions, How many seconds, days.. pass('+', '-'),

Maybe you should try here:
http://msdn.microsoft.com/library/en-us/vclib/html/_MFC_COleDateTimeSpan_Class_Members.asp?frame=true

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

It would really your problem if you could create different functions for different tasks like: 1. Accepting the data 2. Performing the conversions 3. Performing the calculations for the number of tiles. If classes have been introduced in your course you can try creating a class "Room" which will pack all the data and functions in a single abstraction. Incorporate the followign changes and repost. It will also help you get good grades if you perform the task using functions.

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

You get a moderator who doesnt understand what absinthe is ;) I put in a Torque game engine

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

caused him to

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

WAN -> wacky archive network

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

I'm with bumsfeld on this one. You want as much precision as you can get throughout the program's calculations and only round for the display. You don't even want to round the number itself, just the display.

If you round prematurely, all your calculations will be slightly off. And the more calculations you do, the more inaccurate your answer.

It may be quite possible that the data rounded off is not used for calculations or used in calcultions which requires only the rounded off values. It could also be written to a file and used only for data analysis purposes, or maybe the OP had some other idea in his mind or maybe it was part of an assignment given at the college to test his coding skills, you never know.

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

What kind of error you gettting ? Post your entire recent code and highlight the line on which you are getting the error.

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

Have you tried doing google, there are a lot of resources out there to help you get started.

Look HERE and ALSO HERE.