Monday, May 24, 2010

Can there be a multiple main function in one c++ or c program?

Any windows application has only single entry point named "main" for console application or "WinMain" for Windows application. Maybe you need multithreading to start simultaneously multiple functions? I mean something like this:





DWORD WINAPI _Thread1(LPVOID pParam)


{


//do something


return 0;


}





DWORD WINAPI _Thread2(LPVOID pParam)


{


//do something


return 0;


}





void main(void)


{


HANDLE hThreads[2];


hThreads[0] = CreateThread(NULL, 0, _Thread1, NULL, 0, NULL);


hThreads[1] = CreateThread(NULL, 0, _Thread2, NULL, 0, NULL);


WaitForMultipleObjects(2, hThreads, TRUE, INFINITE);


}

Can there be a multiple main function in one c++ or c program?
no!
Reply:you can create multiple functions. However there can only be one Main function
Reply:Main function is the part from where the compiler begins to read the program. Just like a book cannot have two beginnings, a C/C++ program cannot also have two main functions.
Reply:nope!
Reply:No can do...


How does free function work in C language?

How it works exactly is compiler dependent. It may also depend on whether or not you are building with debugging information turned on.





free is going to release memory that you've allocated and return it to the heap for reallocation. Generally, the memory manager as a linked list of blocks of memory that it has allocated. It is going to search the list for your block of memory, remove the link from the allocated list and insert it in the list of free blocks of memory. It may also attempt to merge you block with adjacent blocks of free memory to maximize the size of available blocks.





If you are running Microsoft C++, the debug memory manager will check a couple of bytes that are added to the front and back of the block to be sure that you haven't overflowed when you used it. It will also write a specific byte pattern to the block so that it is easily recognized as deallocated if you use a pointer to it after it has been released.

How does free function work in C language?
i haven't heard about this free function though i am good in C programming. Please give us the enough information about that funcion like its syntax or the header file for that function. So we can understand what you talking about.


Given the function ax2+bx+c, and a is negative, how would you find b?

the y-intercept is also negative





FYI the 2 means squared.

Given the function ax2+bx+c, and a is negative, how would you find b?
Solve the formula for b





ax2+bx+c=0





ax2+c=-bx





ax2+c


--------=-b


x





-(ax2+c)


------------=b


x
Reply:given the function ax2+bx+c, and a is negative, how would you find b?





the y-intercept is also negative


Assume x is a real number





f(x) = ax^2+bx+c


f(0) = c %26lt; 0 , y intercept





from the quadratic equation





x = -b +/-sqrt(b^2 - 4ac)] / 2a


Since a is negative and c is negative, 4ac is positive.


For the radical to be a real number:





b^2 %26gt;= 4ac


b %26gt;= 2sqrt(ac) or b %26lt;= -2sqrt(ac)





That is the best I can do.
Reply:ax²+bx+c


y intercept is negative


a%26lt;0


c%26lt;0


I am calling a function in a C DLL that I wrote from C#. How do I trace into it with the debugger?

you need to start the debugger with the ability to trace into managed and native code.


I have acomplished that by starting the application from the command line, then attached the debugger to the process and in the dialog selected both managed and native code.


In VS2005 go to Debug menu, select attach to process in the dialog that appears in the middle of the dialog you will see where you can select what kinds of code you want to debug.


Hope this helps.

I am calling a function in a C DLL that I wrote from C#. How do I trace into it with the debugger?
Try this instead: under the properties tab of the solution, check 'enable unmanaged code debugging'. You should be able to debug right into the DLL. BTW, if you had, say, c++ code calling managed code (and yes, it can be done), you'd select Debugger Type=mixed under the solution's properties.

lady palm

What is a callback function ? Explain in C , C++ and WIN API environment.?

It was asked in assessment test but I couldn't answer correctly. I'm not familiar with WIN API environment too. Can u plz help me on these ?

What is a callback function ? Explain in C , C++ and WIN API environment.?
Callback function— callback procedure with return value.


Callback procedure— procedure to be called from external execution flow than the execution flow (main) of unit that contains procedure. The description refers to executed unit, ex. binary executable file loaded into memory and executed as *self* operating system task. Such procedure operates out of direct-inherited environment of the main execution flow.


In C simple example of callback function is one passed as argument with "sort()". This function is next used for comparing and is called before "sort()" returns to main execution flow from C library.


[C++— omited answer.]


In Windows API callback functions are used for events (messages) [explained in earlier answer] and reporting states of asynchronous operation.


Usually pointer to callback function is passed as argument to function that initiates some operation.
Reply:A callback function is a function that executes when an event occurrs in the GUI. For example, you press the back button on a browser, and the callback function reloads the previous page. They can respond to clicks, double clicks, key down, key up, Any event.


What printf function returns in C?

printf function returns an integer. were the integer is number of characters it had printed using that printf statement..





Eg:


void main()


{


int i;


i= printf("hai");


}





In the above program i will have a value 3 after the execution of the printf.

What printf function returns in C?
it prints the word you would write in () brackets





dont forget to put /n in the end of the statment





ask any computer related problem here which is a open house resource form





http://airtel-broadband.com/webjockey/cl...
Reply:On success, the total number of characters printed is returned.


On error, a negative number is returned.
Reply:Number of characters output, or EOF if there was a problem.


Never checked it though.


What is function overriding in C++???

Function overriding allows you to write multiple functions with the same name. The compiler differentiates them from each other by the number of and types of the parameters the function takes. The compiler does this by "name mangling". So, for instance, the compiler could internally change





void foo(void); to vFooV(void)


and


void foo(float f); to vFooF(float)





Compilers are free to mangle names any way they want so long as they are consistent. However it is entirely possible that two different compilers will employ entirely different techniques.





The compiler keeps track of which one of the overridden functions is called based on the parameters present in the function call itself.





Note that overriding does not necessarily have anything to do with inheritance. Stand alone functions outside of any class can be overridden.

What is function overriding in C++???
Function Overriding refers to modify the definition of the base class method into the derived class with the same name and signature.





If we change the the definition of a method in a same class but with different signature then it is known as Function Overloading.








Check this out, Function overriding in C++/CLI. http://www.codeproject.com/KB/mcpp/cppcl...
Reply:function overloading is where you can make a function do different things depending on what information you send as parameters to the function.





Actually it isn't the function doing different things, it's multiple functions with the same name that do different things. The function that actually gets invoked depends on what parameters you send.








http://en.wikibooks.org/wiki/Computer_pr...
Reply:Function Overriding happens in the context of inheritance. When a derived class defines a function with the same signature as that from its base class.





e.g you have a base class called vehicle


with a function called "steer vehicle"





maybe you make a class... vehicle :car...


where car, inherits all the properties and functions of vehicle.


and you have the function steer vehicle in the vehicle class.





but now you make a class vehicle: bicycle


and you decide that the steer vehicle function needs to be a bit different, so you can define the function "steer vehicle" again inside the bicycle class. and when you use the steerVehicle function from the bicycle class..... it will use this function, instead of the one from the base class. in otherwords.. over-riding the function in the base class.





hope that makes sense :)


Find the derivative for the function. Assume a, b, c, and k are constants.?

this is calculus. Here's the function.


g(x)=-1/2(x^5 + 2x - 9)

Find the derivative for the function. Assume a, b, c, and k are constants.?
g(x)= -1/2(5x^4 + 2)

snow of june

C++ Programing Help!, usinng 'string' function to create 'ofstream' file name!?

im doing a program for my class. i have to make a 'string' function that takes the name of the ifstream file (data1.txt) and the string function changes that string into 'data1.csv'.





that way, when i go to open my ofstream file (which doesnt exist, so it'll create it), i use the call of the string function so it creates the file 'data1.csv'


....


here is what my function looks like...


string newoutput (string filename)


{


string newfilename;


int p;


filename.find('.');


p=filename.find('.');


cout %26lt;%26lt; filename.substr(0,p) %26lt;%26lt; ".csv";


return newfilename;


}





...then when i go to open the ofstream file, i have it saying...





result.open (newfilename);





....





but it does not compile. i think it has something to do with the way my function is set up. idk if its outputing it right or not. if i change "result.open (newfilename);" to "result.open ("data1.csv");" then it works exactly how it want it to. but my teacher wants me to use the string function. can anyone help me?

C++ Programing Help!, usinng 'string' function to create 'ofstream' file name!?
Your function actually returns the empty string because note that you have not assinged anything to "newfilename" within that function. Also, have you declared "newfilename" before you used it in the following line of code:





result.open (newfilename);





Note that you need to declare "newfilename" before you use it in the previous line (declaring it within the function is not enough because its scope is going to be within that function only).





I have rewritten your code and here is what I have:





string newoutput (string filename)


{


string newfilename;


int p = 0;





p = filename.find('.');


newfilename = filename.substr(0,p) + ".csv";


return newfilename;


}





string filename = "data1.txt";


string newfilename = newoutput(filename);


result.open(newfilename);


Create the sine function without libraries in C++?

ive heard that you can make the sine function without the math library. you have to use something like x-x^2/3!...

Create the sine function without libraries in C++?
Yes! You absolutely can. In fact, all the standard c libraries are simply code that is/was re-written again and again and again, so they finally made it part of the standard library.





//caveat: example only...math is from your own question





double _my_sine(double x)


{


return x-( (x*x) / (1*2*3) );


}





Now, please note we've given this, our sine() function, a unique name that is different than the standard C's math library function...calling this one "_my_sine()".





This is important so the compiler gets/uses the correct sine function, and that we also know which one we're using...
Reply:Dear, Its A Math Question, Not Programming :(


I Really Can Understand That It Is An Assignment Or Something Like That





I Know That Your Instructor Wants You To Understand From Where This Comes From, But I Believe Rewriting Algorithms Will Not Be Useful As Searching To Create New Ones








http://www.homeschoolmath.net/teaching/s...





Hope This Help





You Have To
Reply:Um, to the previous answerer, you don't HAVE to capitalize every word in a sentence.





The definition of function Sine(A) is, for any right triangle with one angle equaling angle A is





Opposite


Sin(A)= ------------


Hypotenuse





You do know what those are, right? (Hypotenuse is opposite the right angle, Opposite is opposite angle A).





UNfortunately, the only ways I know of defining sine are by using other trigonometric functions.


Pi 1


Sin(A)= Cos(------- - A) = ----------


2 csc A





Edit: Follow the site listed below, this text editor doesn't preserve the spacing for the dividing.


Function rule d(c(x))?

is this for math?


if so:


Take the function c(x) and put it in for every x in the function d(x).


So, if


c(x) = 2


and


d(x) = 3x^2 + 5x -1


the new equation would look like


d(c(x)) = 3(2)^2 + 5(2) -1


for a final answer of:


21

sweet pea

The cost function is given as c(w1, w2, q) = q[w1 + w2]. What are the conditional factor demands?

Note the production function is NOT provided and needs to be derived.

The cost function is given as c(w1, w2, q) = q[w1 + w2]. What are the conditional factor demands?
c(w1,w2,q)=q(w1+w2)


The Conditional Factor Demands or CFD is a function to know quantities of inputs. The function is related to output and prices of the different inputs involved.


CFD is more or less x1=x1(w1,w2, Y)


w1=price of input 1 or x1


w2=price of input 2 or x2


Y= total production


Simplify the following function:((A*B*C) + ((NOT A) * B * C) + (A* (NOT B) * C) + (A*B*(NOT C)))?

I m an informatics student. this question is from the course "Logic Design".The course unit no is 254. if there is any info student here then help me to solve it. or if anyone else can solve it then plz do it soon i will thankful to one

Simplify the following function:((A*B*C) + ((NOT A) * B * C) + (A* (NOT B) * C) + (A*B*(NOT C)))?
ABC+A`BC+AB`C+ABC`


(ABC+A`BC)+(ABC+AB`C)+(ABC+ABC`)


BC(A+A`) + AC(B+B`) + AB(C+C`)


BC+AC+AB





This is the simplest form
Reply:The function will return 1, whenever any two variables are 1, hence can be reduced to


AB + BC + AC.
Reply:Try this. "Factor" out the A from three of the terms.





(NOT A)*B*C + A*[ B*C + (NOT B)*C + B*(NOTC)]


Note that B*C+(NOT B)*C+B*(NOT C) = B + C





So we have





(NOT A)*B*C + A* (B+C)





Thats as simple as I can get it....

bottle palm

C++, How do I create a pointer to a class member and pass that pointer as a parameter to a function?

C++, How do I create a pointer to a class member and pass that pointer as a parameter to a function?

C++, How do I create a pointer to a class member and pass that pointer as a parameter to a function?
http://www.cprogramming.com/tutorial/les...
Reply:create an obect of the class of pointer type, then pass the perticular member of the class as the parameter to the function only if the member u want to pass is declared as public.


Hw 2 rite a function least() that takes an ifstream parameter named infile as a changing inpt parameter in C++

How to write a function least() that takes an ifstream parameter named infile as a changing inpt parameter in C++. It returns an integer value that is the lowest value read from teh file

Hw 2 rite a function least() that takes an ifstream parameter named infile as a changing inpt parameter in C++
We don't do homework here. Here's the basics. Do the rest yourself and come back if you have problems.





int least(ifstream%26amp; infile)


{


//.........


}


Function members in c++?

when i make an object example: from stack or Queue, it should give the list of the functions like "pop, push,..." when i write "." , is there away to activate it?

Function members in c++?
Well it really depends on what ide you are using. If you are using Visual Studio it should come up by default. If you are using another ide look for something like intellisense. However not all IDE's have this feature.


[Linear] Function, Help; Ax+By=C?

Hello guys,





Well, functions have me completely stumped. I am currently bluffing my way through Algebra I (advanced, 8th grade =/), and we hit functions yesterday - they have me completely stumped.





Specifically linear functions. It goes without saying (right?) that exponents, variables/constants in fractions, multiplying y and x, etc. disqualify them as linear functions, correct?





Regardless - I need help.





4y-2x=0





"Tell whether each function is linear. If so, graph the function."





So basically, I know it is linear, and I know how to graph - where do I go from there? The Algebra I teacher is a cool guy, he got us started on y=mx-b a long time ago, but I never under stood. I THINK I have to get y on its own, just like any equation's variable.





So would it be





y-1/2x=0? Where would I go from there?





/dying





By the way - why use (f)x, instead of y? I never understood - in some later stage of math, do the extra variables help you plug in factors and what not?

[Linear] Function, Help; Ax+By=C?
hi...





you seem to know your algebraic processes ... at least... so it still counts...





Ax + By + C = 0 is called the standard form or the general form of the linear equation. A, B %26amp; C are fixed constants...





so you know how to transform it...so that y has a coefficient of 1...





4y - 2x = 0


you now have... y - 1/2 x = 0


you just need to transpose the second term..


y = 1/2 x ...... (this is now called the slope-intercept form of the line) ... it has the form y = mx + b





thus in your example... m = 1/2 is the slope


b = 0 is the y-intercept...








Regarding the other notation...


y = mx + b ...


it is still the same as f(x) = mx + b ... this is just another way of writing the function... f(x) and y are totally interchangeable...


this is just one way of writing the function so that it will be clear that the independent variable is x.





btw... i know you know that that notation is NOT 'f multiplied to x'.


you read that as... "f of x".








§
Reply:Move the x to the RHS


y = 1/2x. And done.





By the way - why use (f)x, instead of y? I never understood - in some later stage of math, do the extra variables help you plug in factors and what not?


—Something like that, yes. Just wait.
Reply:from y - (1/2)x = 0, add (1/2)x to both sides, getting y = (1/2)x, which of course is linear, y = mx + b with m = 1/2 and b = 0.





f(x) makes you think of the result of doing stuff to x to get y, the stuff you do is what the function rule describes. Just think of the f(x) as y.
Reply:okay have y by itself on one side of the equation to put it in slope-intercept form:





y= 1/2x





To graph you would look for a y intercept (the b ) which is zero here. y=m(slope)x + b(y-intercept)





so put a point on the graph at the origin to mark the y-int.


Then the slope is rise/run. which means rise 1 unit and run horizontally to the right 2





in other words up 1 over 2 and you have your graph. repeat the whole up 1 over 2 thing until your graph runs out. or go negatively by down one left 2 (just the opposite) that will give you the same thing





hope this helps!





and you will use f(x) because y is actually a function of x. so they shorten it to f(x) and it will make complete sense when you move through math classes

magnolia

Largest open interval of convergence for the power series about c=0 representing the function f(x)=2/(x^2 +4)?

...don't worry about endpoints





possible solutions...





a. (-1/6, 1/6)





b. (-1/4, 1/4)





c. (-1/3, 1/3)





d. (-1/2, 1/2)





e. (-1, 1)





f. (-3/2, 3/2)





g. (-2, 2)





h. (-3, 3)





i. (-4, 4)





j. none of these

Largest open interval of convergence for the power series about c=0 representing the function f(x)=2/(x^2 +4)?
d


Verify that the given function y is a solution of the ODE for any value of C?

Verify that the given function y is a solution of the ODE for any value of C. a.) y+y'=1, y(t)=1+Ce^(-t) b.) yy'=t, y(t)=Sqrt(t^(2) + C) c.) y'+6y=0, y(t)=Ce^(-6t)

Verify that the given function y is a solution of the ODE for any value of C?
This is pretty easy, just plug the given equation into the ODE and make sure it works. I'll do (a) and (b), see if you can do (c) for yourself.





(a): y + y' = 1, y(t) = 1 + Ce^(-t).


Well, we're given y, we obviously need to find y' to make sure the ODE works. So differentiate:


y'(t) = 0 + Ce^(-t).(-1) = -Ce^(-t)


Then the LHS of the ODE is y + y' = 1 + Ce^(-t) + (-Ce^(-t))


= 1 as required.





(b) y y' = t, y(t) = √(t^2 + C)


Again we need to differentiate so we can substitute the expression for y' into the equation of the ODE:


y' = d/dt (t^2 + C)^(1/2)


= (1/2) (t^2 + C)^(-1/2) . (2t)


= t / √(t^2 + C)


So substituting into the LHS of the ODE gives


y y' = [√(t^2 + C)] . [t / √(t^2 + C)]


= t as required.





Note that (c) is quite similar to (a). As I said, I'll let you do that one for yourself.


If f is a constant function and (a,b) is any open interval, prove that f(c) is both a local and an absolute ex

If f is a constant function and (a,b) is any open interval, prove that f(c) is both a local and an absolute extremum of f for every number c in (a,b).

If f is a constant function and (a,b) is any open interval, prove that f(c) is both a local and an absolute ex
This is checking the definitions carefully.





Local: f'(c) = 0 since f is constant. Since the domain (a,b) is an open interval, there are always c1 %26lt; c %26lt; c2 with f(c) %26gt;= f(c1) and f(c2), same for %26lt;=.





Global: For every x in (a,b), f(c) %26gt;= f(x) (global max) and f(c) %26lt;= f(x) (global min)


How can I get value of R L C when they are connected in series in a box.And we are given CRO & function gentor

AN R L C is given in a box and we are to determine value of these R L C .how can I do it using a CRO and function generator.we are allowed to change input patterns with function generator

How can I get value of R L C when they are connected in series in a box.And we are given CRO %26amp; function gentor
Using your Oscilloscope and function generator.


Start by using a standard sine wave in and measure the output.


Change the frequency.


Change to a Square wave and again change the frequency. Try a long duty cycle which is almost equal to a DC input, what is the signal output. This will determine the RC time constant.


Then you use the Frequency relationship to determine L. Where impedance Z = 2pf * L and for C: Z = 1/(2pfC)


Where p = pi= 3.14 and f = frequency.


You Also know that Zeq (Z equilvalent for L %26amp; C) + R at resonant frequency gives the highest Current I.

forsythia

How do I transfer an array table to a function as a parameter in the syntax programming of C++?

I just solve informatic problems in c++. I have a string array of data which I want to make some comparing with a temp string array so it can move on. That's easy. I use loops and ifs. But the problem is that I use it many times and I want to organize my program. Therefore, i intend to pass the string array of data as a parameter in a particular function. In fact, I would really be appreciated if I can transfer a parameter data type of a string array by reference. Anyways a lot of help would be appreciated.

How do I transfer an array table to a function as a parameter in the syntax programming of C++?
char strArray[][6] = {"AAAAA", "BBBBB", "CCCCC", "DDDDD", "EEEEE"};





int stringCount = sizeof(strArray)/sizeof("AAAAA");





int TestStringArray(char A[][6], char B[])


{


for(int i = 0; i %26lt; stringCount; i++)


{


if(0 == strcmp(A[i], B))


{


return i;


}


}


return -1;








}








void main()


{


char B[] = "EEEEE";





int result = TestStringArray(strArray, B);


}


How can i compute 10 to power m using for loop in c++ (without using function power) ?

where m is nonnegative integer

How can i compute 10 to power m using for loop in c++ (without using function power) ?
Here is pseudocode





temp =1


for a = 1 to m


temp =10*temp


end





This is a simple question about the nature of a power.


if you wanted to use the function exp you could also do it well





y = 10^m


log(y) = m*log(10)


y=exp(m*log(10))





its a one-liner and a cheap shot. If your teacher wants you to show a loop and an understanding of how loops and the definition of a power works, this isnt going to do it.


If you are looking for a fast one-liner from a standard (optimized) library then this might work.





Depends on why you want it.
Reply:y = 10


for 1 to m


{y = y*10


m = m + 1}


endfor





something to that effect
Reply:10 to power m (denoted 10^m here), is the same as 10 multiplied by itself in a loop that lasts for m cycles. 10 is unique because 10^m is the same as 1 with m zeros behind it - so you can also use a loop to just keep adding zeros to a print output.
Reply:long int r = 1;


for(long int x=0;x%26lt;=9;x++){


r *= 10;


}


Change to adjust to what power you want to raise 10 to.


r must be one, I used long because int can sometimes be too short since the furthest it could calculate is 10 to the 4th power.
Reply:Here is some pseudocode that you may find helpful:





result = 1


for i=1 to m


result = result * 10


end for


output result





Alternately, you could do it by means of a recursive function and avoid a loop altogether.


I want to get a c++ code contaning a function on library system?

c++ fuction

I want to get a c++ code contaning a function on library system?
void f() {





}


C++: How do you edit a character string in a different function than the one you declared it in?

The following code is C++:








#include "stdafx.h"


#include %26lt;iostream%26gt;


#include %26lt;fstream%26gt;


#include %26lt;string%26gt;


using namespace std;





int rewriteString(char *str)


{


str = "I want to output this!";


cout %26lt;%26lt; str;


return 1;


}





void main()


{


int meaninglessInteger = 0;


char str[] = "Why am I outputting this, instead of what I want to output?";


meaninglessInteger= rewriteString(str);


cout %26lt;%26lt; str;


system("PAUSE");


}





******* ******* ******* ******* ******* ******* ******* ******* *******


The above code doesn't work. I wondered if someone could help me understand what I need to change to accomplish what I'm trying to do.


I hope the code is fairly self-explanitory: I want to declare a character string in main() and then use a function called rewriteString() to change the message contained in that character string.





What's the correct way to do this? Any help is appreciated greatly!

C++: How do you edit a character string in a different function than the one you declared it in?
just my two cents ;)





int rewriteString(char *str)


{


strcpy(str,"output");


cout %26lt;%26lt; str;


return 1;


}
Reply:Okay. There is actually a very simple explanation to your answer. Once i tell you, you'll wonder why you didnt think of this in the first place.





Now, from basic C++ programming, you'd know this simple example:





void foo( int f ) { f = 25; }


void main() { int a = 10; foo(a); cout %26lt;%26lt; a; }





Now what do you think will be the output. Correct, it will be 10.


Why? Because the argument f to function foo was "passed by value" variable 'a' never changes its value. Now... just extending this to character strings.





void foo( char * f ) { f = "please please change"; }


void main() { char * t= "dont want to change"; foo(t); cout %26lt;%26lt; t; }


Now, :) i think by now you'd be saying "aaah, hmm... ". So, the solution. If you havent caught on, i'll tell you (this is Yahoo! Answers after all).. you've got two options


1. Pass parameter by reference ... void foo( char *%26amp; f )


2. Pass a pointer to the argument... void foo( char ** f )





I think you can figure out the rest. Due to the lack of availability of a compiler to check my analysis. I might be mistaken over char *%26amp; f... it might be, char %26amp;* f . But i dont think so. Sorry, but you'll have to check that.





Thanks.
Reply:I'm sorry if this is not what you want but I find it easier to just do this...





#include %26lt;iostream%26gt;


#include %26lt;fstream%26gt;


#include %26lt;string%26gt;


using namespace std;





char *rewriteString(char *str)


{


char * random = "theText";


return random;


}





int main() {


char * str = new char[100];


str = "Why am I outputting this, instead of what I want to output?";


str = rewriteString(str);


cout %26lt;%26lt; str;


system("PAUSE");


return 0;


}





===


I have no clue why you have the meaninglessInteger variable

jasmine

Find the value of c that makes the function continous?

f(x) = 2x + 9 for x%26lt; or = 3


-4x + c for x %26gt; 3

Find the value of c that makes the function continous?
2(3)+9=-4(3)+c


15=-12+c


c=27


Find the value of c that makes the function continuous?

f(x)={ 2x+9 for x%26lt;(or equal to)3


-4x+c for x%26gt;3

Find the value of c that makes the function continuous?
Set the two segmented equations equal to each other at x=3: 15=-12+c so c=27
Reply:mathforum.org will help with all types of math it works


Find the value of ''c'' that makes the function continuous?

f(x) = {2x+9} for x%26lt; or equal to 3 and {-4x+c} for x%26gt;3

Find the value of ''c'' that makes the function continuous?
f(3) = 2*3 + 9 = 15


lim f(x) as x approaches 3+ is (-12 + c)





-12 + c = 15


c = 15 +12 = 27





The function will be continuous if c=27.
Reply:f (x) = (2x + 9) being a polynomial is continuous for all values of x %26lt; or equal to 3.





f(x) = - 4x + c being a polynomial is continuous for all values of x %26gt; 3.





Now, for function to be continuous at 3,





Left-hand limit of f(x) at x = 3, right-hand limit of f(x) at x =3 and the value of the function for x =3 must all be equal.





Left-hand limit of f(x) at x = 3 is 2*3 + 9 = 15


Right-hand limit of f(x) at x = 3 is - 4*3 + c = -12 + c


Value of the function at x = 3 is 2*3 + 9 = 15





So, -12 + c = 15


=%26gt; c = 27
Reply:Find the value for c where lim (x→3-) f(x) = lim (x→3+) f(x)


In other words, solve for the equation for c





2(3) + 9 = -4(3) + c


=%26gt; c = 27


In the programming language C++, what does the function exit() do, and how do you use it?

I understand that it is a command to exit the program, but what I *don't* understand is why I see a number inside the () as a parameter. In some examples, I see people calling the function and it looks like this: "exit(8);". What is the 8 doing inside the parentheses...?

In the programming language C++, what does the function exit() do, and how do you use it?
It is a return code from the program. The shell that ran the program can check to see if the program exited with an error or normally. I believe return 0 is for normal exit, and return anyother number is for an error.

crab apple

Please Math help for what value of the constant c is the function f continuous on (-infinity, infinity)?

its a piece wise funtction


f(x) = cx^2 + 4x if x%26lt; 2


x^3 - cx if x more than or equal to 2





Thank you for your help!

Please Math help for what value of the constant c is the function f continuous on (-infinity, infinity)?
AT x=2 one formula gives 4c+8 and the other give 8-2c. For the function to be continuous these two values should be equal.





4c+8=8-2c.





So c=0.
Reply:For what value of c is f(x) = cx^2 + 4x continuous? Well, isn't it continuous for all values of c? You're going to have a parabola for any non-zero value of c, and the line f(x) = 4x if c = 0. All parabolas and the line f(x) = 4x are continuous, so c can take any real value.


How to write c coding for forecast function in microsoft excel?

statistical function

How to write c coding for forecast function in microsoft excel?
You would need to know the method used. Its a kind of curve fitting algorithm. Then it just evaluates the curve for the points that you want.





That means, for instance, that you have payments for every month for the past year. Your X coordinates are the dates each month and the Y coordinates are the dollar amounts. Then you fit a curve to those points and get the Y coordinates for the next 12 X coordinates.


Which body system performs the function in human? a. circulatory system b. digestive system c. excretory syste

which body system performs the function in human? a. circulatory system b. digestive system c. excretory system d. tespiratory system

Which body system performs the function in human? a. circulatory system b. digestive system c. excretory syste
Pls, explain further your question. Every organ system of the human body has its own function. The question is: "What is the function you are referring to?".
Reply:I tried to answer this earlier, but realized it makes no sense. Each system you described is a system that does the function that its named for. Perhaps you mean what parts of the body are part of those systems? Just elaborate since this question is presently nonsensical.
Reply:Unfortunately, your question requires further specifics. Based on your multiple choice responses, each of the systems mentioned are necessary. Please, rephrase so that an accurate answer can be provided.


Thanks,


Ruth


Help please, need a sample code in C++ with ReadMemoryProcess() function.?

I am trying to learn how to read memory of other applications.

Help please, need a sample code in C++ with ReadMemoryProcess() function.?
You cannot do it.
Reply:can you post your requirment in http://expert.allexpert.info/


many programmer bit your project.

strawberry

How to plot function in matlab or maple for example {(F/M)/(k-c)^2+ω^2}*{exp(-kt) – exp(-ct)*[cosωt-{(k-c)/(ω)

in above f is force and constant and m is mass and k,c is constant.just tell me how to plot this function.

How to plot function in matlab or maple for example {(F/M)/(k-c)^2+ω^2}*{exp(-kt) – exp(-ct)*[cosωt-{(k-c)/(ω)
t = t_start:h:t_end;


y = {(F/M)/(k-c)^2+ω^2}*{exp(-k*.t) – exp(-c*t)*[cosω*.t-{(k-c)/(ω) ;


plot(t,y);





(t_start, t_end) is the interval of time on which you want to plot the function


h is the time step eg. h= 1 second or h = 0.1 second


Suppose f:C->C is a holomorphic function of form f(x,y)=u(x)+iv(y). Show f(z) is degree 1 polynomial in z.?

C is complex field. holomorphic means analytic or complex differentiable.

Suppose f:C-%26gt;C is a holomorphic function of form f(x,y)=u(x)+iv(y). Show f(z) is degree 1 polynomial in z.?
There's a theorem about if f = u + vi is analytic, then u(sub)x = v(sub) y and u(sub)y = -v(sub)x (where by (sub) I'm meaning the partial derivative). Or that's as best I remember it (it's been a little while since I took Complex Analysis). The Cauchy theorem I think it's called.





The only way f can satisfy the first equation is if it is of the form kz + c.


Let f be an analytic function defined on the unit disc D={z in C:mod(z)<1}.if mod(f(z))</=1-mod(z) for each

let f be an analytic function defined on the unit disc D={z in C:mod(z)%26lt;1}.if mod(f(z))%26lt;/=1-mod(z) for each z in D,show that f is the zero function on D

Let f be an analytic function defined on the unit disc D={z in C:mod(z)%26lt;1}.if mod(f(z))%26lt;/=1-mod(z) for each
Fix z in D. By the maximum modulus theorem for analytic functions, for r with |z| %26lt; r %26lt; 1, |f| either has no local maximum in { w : |w| %26lt; r } or is constant on that domain. Thus





|f(z)| =%26lt; sup { |f(w)| : w in C with |w| = r } =%26lt; 1 - r.





Since the r chosen was arbitrary, it follows that |f(z)| = 0, from which we deduce that f is zero on D.


For what value of the constant c is the function f continuous on (-infinity, inf.) where f(a)=(ca+5 if a?

(-inf,6] or ca^2-5 if a (6,inf)

For what value of the constant c is the function f continuous on (-infinity, inf.) where f(a)=(ca+5 if a?
obviously the function is continuous everywhere except at a=6, no matter what c is. So compute the two values at 6 (which technically are the left and right limits of the function at 6.)


get 6c+5 (left) and 36c-5 (right)


equate


6c+5 = 36c-5


30c=10


c=1/3

kudzu

(c) Determine the Taylor polynomial of first order for the function f(x,y)=exy+ey at the origin.?

(c) Determine the Taylor polynomial of first order for the function f(x,y)=exy+ey at the origin.

(c) Determine the Taylor polynomial of first order for the function f(x,y)=exy+ey at the origin.?
f(x,y) = f(0,0) + fx(0,0) (x-0) + fy(0,0)(y-0)


fx = yexy at the origin the value is 0.


fy = xexy + ey at the origin the value is 1.





f(x,y) = 2 + y.





I am assuming that exy + ey means e^(xy) + e^y.





d:


Sample c++ program using a function?

can u mail me a program that is using a fuction??????? prompt the user inside the function.... i like the prog... computing the GrossPay w/ the formula GrossPay=no. of days worked*daily rate......... tnx..

Sample c++ program using a function?
No, I can't. Do your homework yourself please, that's how you learn. And please try to speak English next time, thanks.





If you have a specific problem and/or question about the program as you write it, please feel free to ask.
Reply:Here's a quickie I threw together in a few minutes:





#include %26lt;iostream%26gt;


using namespace std;





double calculate (double hours, double rate);








int main() {


double hours,rate,gross;


cout%26lt;%26lt;"Enter hours worked:"%26lt;%26lt;endl;


cin%26gt;%26gt;hours;


cout%26lt;%26lt;"Enter rate:"%26lt;%26lt;endl;


cin%26gt;%26gt;rate;


gross = calculate(hours,rate);


cout%26lt;%26lt;"Gross pay: "%26lt;%26lt; gross;


return 0;





}





double calculate (double hours, double rate){


double grosspay;


grosspay = rate * hours;


return grosspay;


}


Find the limits of a, b, c for the function f(x) = 3x/x-4 use neg. infinity and infinity where appropriate?

lim f(x)


x-%26gt;4 -





lim f(x)


x-%26gt;4+





lim f(x)


x-%26gt;4

Find the limits of a, b, c for the function f(x) = 3x/x-4 use neg. infinity and infinity where appropriate?
first one is negative infinity since when you approach 4 from the left, x - 4 %26lt; 0





second one is positive infinity





third is undefined since the left limit does not equal the right limit
Reply:dude..


C-programming with primitiveGCD function?

c program

C-programming with primitiveGCD function?
yeah, absolutely! Very good question. Shows a brilliant mind.
Reply:U haven't stated what do u need, recursive or non-recursive program. Since u've asked for primitive one, I think u need the Euclidean algo. for GCD.





//Prog. to get G.C.D. of two integers using Euclidean Algorithm


// ( without recursion )...................................





#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;





main()


{


int a,b,c,d ;


clrscr() ;


printf("\n Enter 2 integers ") ;


scanf("%d %d",%26amp;a,%26amp;b) ;


if( a%26lt;b )


{


a=a+b ;


b=a-b ;


a=a-b ;


}


while( a%26gt;b )


{


c=a/b ;


d=a-b*c ;


if( d==0 )


break ;


a=b ;


b=d ;


}


printf("\n Required G.C.D. of two entered nos. = %d ", b) ;


getch() ;


}

garland flower

For which value(s) of c is the function T continuous on (-infinity, +infinity)?

T(x)={ cx^2-2x , if x %26gt;/= 2;


{ x^3-cx , if x%26gt; 2

For which value(s) of c is the function T continuous on (-infinity, +infinity)?
lim T(x )for x==%26gt;2+ = 4c-4


limT(x) x==%26gt;2- =8-2c


4c-4=8-2c so 6c=12 and c=2


C program using a function?

I need to create a function that creates a text file. Have the user enter text one line at a time into the text file, and stop only when he types “the end”. I have this so far, what do i need to do finish it?





#include %26lt;stdio.h%26gt;


int main()


{


FILE *fout = fopen("out.txt", "w");


char sentence[100];





if(fout == NULL) {


printf("Error opening file\n");





return 0;


}





printf("Enter a sentence : ");


while(scanf("%s", sentence) != EOF)


fprintf(fout, "%s", sentence);


fclose(fout);


return 0;


}

C program using a function?
Hi tbwada,





essentially, you need to modify your while loop condition to compare the sentence value with "the end":





strcmp(sentence, "the end")





this will return a zero if a match has been found. I haven't compiled this, but I think it should what you want:





#include %26lt;stdio.h%26gt;


int main()


{


FILE *fout = fopen("out.txt", "w");


char sentence[100]="";





if(fout == NULL) {


printf("Error opening file\n");





return 0;


}





printf("Enter a sentence : ");








do


{


fprintf(fout, "%s", sentence);


scanf("%s", sentence);


}


while ( (strcmp(sentence,"the end")!=0) );





fclose(fout);


return 0;


}





note: the fprintf and the scan are reversed so that when you do type "the end" it's not printed to the file.
Reply:try this:


#include%26lt;iostream.h%26gt;


#include%26lt;string.h%26gt;


#include%26lt;stdio.h%26gt;


int main()


{


char sentence[100];


FILE *fout=fopen("out.txt","w");


if (fout==NULL)


{


printf("Error opening file\n");


return 0;


}


do


{


cin.get(sentence,100);


cin.get();


fprintf(fout, "%s\n", sentence);


}


while(strcmp(sentence,"the end"));


fclose(fout);


}
Reply:inside ur while loop ceck for the sentence


while(...)


{


if(strcmpi(sentence,"the end")==0)


break;


fprintf(fout, "%s", sentence);





}


C++ QUESTIONS consider the function prototype?

consider the function prototype below





bool max_of_List(float List[],int size_of_List,int *where);





Judge each of these arguments whether it is passing-by-value,passing-by-address,or passing-by-reference? Why?

C++ QUESTIONS consider the function prototype?
that sounds like a exam question...uhmm I'll get you started.





List = reference, is an array, ALL arrays in C++ are passed as reference


size = value, is the size of the array, not meant to be modified and there is no %26amp; next to it, so it's value...





where = ..... I'll tell you, it's a pointer to an int...what do you think it is ?





there you go...
Reply:1st parameter pass by reference


2nd pass byvalue


3rd pass by reference
Reply:First of all u have no pass by refernce type arg in this prototype





As far as i infer i think that this function should get a list of float values as first arg, the size of this list as second arg and the third arg is used to send the position of max number to the calling function





1. the first arg is pass by address since arrays implicitly pass addresses


2.The second one is obviously normal pass by value


3.The third one is also pass by address as u recieve it using a pointer the calling function should definetly pass address


by passing the variable with '%26amp;' qualifier.





Ha-p Coding..


C++ Help (Recursive Fibonacci Function)?

I don't understand how to create a function that returns the n-th Fibonacci number.





thanks in advance

C++ Help (Recursive Fibonacci Function)?
Here is your answer, the first function is what you asked for, the main() function shows you how to call (use) it:





int Fibonacci(int nNumber)


{


if (nNumber == 0)


return 0;


if (nNumber == 1)


return 1;


return Fibonacci(nNumber-1) + Fibonacci(nNumber-2);


}





// And a main program to display the first 13 Fibonacci numbers


int main(void)


{


using namespace std;


for (int iii=0; iii %26lt; 13; iii++)


cout %26lt;%26lt; Fibonacci(iii) %26lt;%26lt; " ";





return 0;


}
Reply:This page shows the fibonacci formula:





http://en.wikipedia.org/wiki/Fibonacci_n...





Once you understand the formula, put it into psuedocode:





Take in a number.





If the number is 0 or 1, return that number.





Else





Return the result of f(n-1) + f(n-2)





Then put it into code:





long fib(unsigned long n) {


if (n %26lt;= 1) {


return n;


} else {


return fib(n-1)+fib(n-2);


}


}
Reply:i e-mailed you all the instructions


jk

blazing star

Find the point(s) c guaranteed by the Mean Value Theorem for the function f(x)=(x+1)/x on the closed interval?

Find the point(s) c guaranteed by the Mean Value Theorem for the function f(x)=(x+1)/x on the closed interval [1/2, 2]





Thanks

Find the point(s) c guaranteed by the Mean Value Theorem for the function f(x)=(x+1)/x on the closed interval?
The Mean Value Theorem says





"If a function f is continuous on [a, b] and differentiable on (a, b), then there exists at least one c in [a, b] such that f'(c) = (f(b) - f(a)) / (b - a)."





We want to find all numbers c that satisfy that equation above.





In this case, a = 1/2 and b = 2, and f(a) = f(1/2) = 3, and f(b) = f(2) = 3/2.





So the Mean Value Theorem guarantees that there's a c such that





f'(c) = (f(b) - f(a)) / (b - a) = (3/2 - 3) / (2 - 1/2) = (-3/2) / (3/2) = -1.





We must find all points in the interval [1/2, 2] where the derivative of f is -1. So let's differentiate f:





f(x) = (x + 1)/x, so


f'(x) = -1/(x^2)





For which x does this equal -1?





-1 = -1/(x^2)


1 = 1/(x^2)


x^2 = 1


x = -1, 1





Only x = 1 is in our interval, so this is the unique point where the derivative is -1.





Thus, c = 1 is the point which satisfies the Mean Value Theorem. (In some cases, there might be more than one value for c, but in this problem there is only one.)


Simple C++ source file and function problem?

I'm trying to create a simple program that prints the word "Hello" to the console. However, I want the program to use two different functions, the first being the main and the second being a void function that prints the word to the console. When I try to compile, it tells me there is an error at second2.h on the line that tries to print to the console (the line with cout). I was wondering what I did wrong.


Here is the code from main.cpp:


--------------------------------------...


include %26lt;cstdlib%26gt;


#include %26lt;iostream%26gt;


#include "second2.h"


using namespace std;





void sayHello();


int main(int argc, char *argv[])


{


sayHello();


system("PAUSE");


return EXIT_SUCCESS;


}


--------------------------------------...


the code from second2.h:


--------------------------------------...


#include %26lt;cstdlib%26gt;


#include %26lt;iostream%26gt;


void sayHello()


{


cout %26lt;%26lt; "Hello" %26lt;%26lt; endl;


}


--------------------------------------...





Thanks.

Simple C++ source file and function problem?
Just a guess:





Try moving the using namespace std; before the #include "second2.h", which, as someone else has pointed out, shouldn't include the sayHello() function definition, just its declaration.





I'm thinking your compiler requires the namespace be already pulled in for cout, which, as your code is currently configured, it isn't when sayHello() is compiled.





Good luck.





By the way, any compiler that just says there's an error on line such-and-such without giving any details should be evicted from your machine..
Reply:It cant compile, first line should be #include... and not include...


you should not declare sayHello in the cpp file it is already included in second2.h


I hope EXIT_SUCCESS is defined I don't use this macro.
Reply:You do have a compiler issue (your exact program compiles with Borland for example with the extra # for include first line) but you should be able to compile this with more rigid code.





Function declarations should be in header files so that other .c files can see them without explicitly extern-ing them.





Function definitions should always be in .c files.





That will suit all compilers.





So second2.h should just have





extern void sayHello();





Ths means there is a single place where the function is extern-ed and made available to other files.





Your main file





void sayHello()


{


cout %26lt;%26lt; "Hello" %26lt;%26lt; endl;


}





int main(int argc, char *argv[])


{


sayHello();


system("PAUSE");


return EXIT_SUCCESS;


}





If no other file requires the sayHello function then it ought to be declared as static in the same file as the function definition.
Reply:--- main.cpp ---


#include %26lt;iostream%26gt;


#include "2nd.h"


int main()


{


hello();


system("PAUSE");


}





--- 2nd.h ---


#include %26lt;iostream%26gt;


using namespace std;


void hello()


{


cout %26lt;%26lt; "Hello World!\n";


}


Saturday, May 22, 2010

Search function using a keyword on a text file in C#?

Just want to know if its possible to do a search function using a keyword on a text file in C#.





For example,


lets just call the text file test.txt, and the content of the file is





BOOK xxx,yyy,zzz


AUTHOR xy, yx, yy


YEAR 1999,1929,2009


PRICE 99,77,195


COMMENT very very good


MAGAZINE asd,avacs,etc


COVER hard, soft








So BOOK is the keyword and AUTHOR, YEAR, PRICE and COMMENT are sub-keywords marked by spaces before the words(likewise for MAGAZINE and COVER).


What I'm after is when user type in keyword BOOK, it returns the whole 5 lines starting from BOOK to COMMENT. And when user types in PRICE, it returns only 1 line(PRICE 99,77,195).





The output could be just a display in the console.





TextReader tr = new StreamReader("test.txt");


String contents = tr.ReadToEnd();


String keyword = "BOOK";





Could anyone help me with the searching part? dont worry about indentations for now, just a quick search for the word BOOK on "contents" would be superb.

Search function using a keyword on a text file in C#?
Use the method IndexOf





if (contens.IndexOf(keyword) %26gt;= 0)


{


// string in array


}


What is the difference between C and C++ regarding main() function?

in c main can return void but not in c++


in c++ it alsways return an int

What is the difference between C and C++ regarding main() function?
the main function isn't much different however
Reply:The main diffterence between c and C++ is that


C is a structured language WHILE


c++ is object oriented language.

imperial

Express the monthly cost C as a function of the distance driven d, assuming that a linear relationship gives a

The monthly cost of driving a car depends on the number of miles driven. Lynn found that in May it cost her $380 to drive 480 mi and in June it cost her $460 to drive 800 mi.

Express the monthly cost C as a function of the distance driven d, assuming that a linear relationship gives a
Note: "Linear" means straight-line. So we can plot a straight line graph to find the relationship.


Let d = # of miles driven


Let C = cost





So we have:


480 miles = $380


800 miles = $460





Then the points on a graph are: (480,380) and (800,460).





Find the equation of a line passing through these points and you're done.


Gradient = (C2-C1) / (d2-d1)


= (460-380) / (800-480)


= 80/320


= 0.25





So the equation of a line is:


C-C1 = m(d-d1), where m is the gradient and (d1,C1) is a point.


Let's use: (480,380) as the point (d1,C1)


Then the equation of the line is:


C - 380 = 0.25(d-480)


C - 380 = 0.25d - 120


Add 380 to both sides:





C = 0.25d + 260





The equation of the line is the same as the linear relationship. Therefore our final answer is:





C = 0.25d + 260
Reply:C = ($460 - $380)(d - 480)/(800 - 480) + $380
Reply:If it is a linear function then


Cost, c = kd + p, where d = distance, k ,p are constants





Eqn 1: 380 = 480k + p, for May


Eqn 2: 460 = 800k + p, for June





Eqn 2 - Eqn1:


80 = 320k


k = 1/4





Now put k=1/4 into 1


380 = 480/4 + p


p = 380 - 120 = 260





hence, c = d/4 + 260
Reply:For 480 miles we have 380$


For 800 miles we have 460$





We can subtract the two giving:


For each additional:


320 miles - 80$


160 miles - 40$


480 miles - 120$





Subtract this from the first item:


0 miles - 260$





C = md + 260 (m is gradient)


m = 40 / 160


m = 1 / 4


m = 0.25





C = 0.25d + 260


C++ returning enumeration from function?

How do i go about returning an enumeration from a function?





via global pointer?





i.e





int myFunction()


{


if(x=1)


{


enum value {val1 = 1, val2 = 2}


}


else


{


enum value {val1 = 2, val2 = 3}


}


}





How would I go about passing the enum back to the main function? Thanks!

C++ returning enumeration from function?
enum is not a type by itself, it's a type category. A variable can't be of type enum, it could only be of a specific enum type.





So, your syntax is not valid.


Here is an example:





enum TypeColor


{ RED, BLUE, GREEN, OTHER};





TypeColor GetColor(char* in_colorName)


{


TypeColor VarColor = OTHER;


if (stricmp(in_colorName, "red" == 0))


VarColor = RED


else if (stricmp(in_colorName, "blue" == 0))


VarColor = BLUE


else if (stricmp(in_colorName, "green" == 0))


VarColor = GREEN;


return VarColor;


}





int main()


{


TypeColor myColor = GetColor("green");


}
Reply:Check this out... maybe it will help.





http://www.thescripts.com/forum/thread68...
Reply:When you declare an enumeration, it's like you are declaring a new data type. The caller of the function must have access to the declaration, and the funciton itself needs access to it. In your example, you'd probably declare it globally, before any code needs to use it. Don't declare the enum inside a function.





Here's a rewrite of your code.





//First, declare and define the enum:





enum value {val1 = 1, val2 = 2};





value myFunction(int x) //function returns type 'value'


{


value retval;





if (x == 1) //DOUBLE equals here!!


{


retval = val1;


}


else if (x == 2)


{


retval = val2;


}





//TODO: decide what you want to do if it's neither!!





return retval;


}





The calling code would look like this:





value val = MyFunction(1);


Why does error "Illegal use of floating point value in function main()" in C++ code?

I'm doing a decimal to binary, octal and hexadecimal converter using C++. Actually, the code is still unfinished and I haven't started with the octal and hexadecimal part. Here's the code:





#include %26lt;iostream.h%26gt;


#include %26lt;math.h%26gt;





int main ()


{


double input, i, j, k, bin, oct, hex, counter, power;


char ans = 'y';





do


{


bin = 0;


oct = 0;


hex = 0;


counter = 1;


i = 1;


j = 1;


power = 1;


k = 0;





system ("cls");





cout %26lt;%26lt; "Enter an integer number [1-50]: ";


cin %26gt;%26gt; input;





while (counter %26lt; input)


{





while (i %26gt; 0)


{


j = i % 2;


k = k + pow(j,power);


power = power + 1;


}





cout %26lt;%26lt; bin;


}





} while (ans == 'y' || ans == 'Y');





return 0;


}

Why does error "Illegal use of floating point value in function main()" in C++ code?
First, almost all of your variables should probably be int, not doubles (floats). Unless you're dealing with possible fractional values (currency, for example) or potentially very large numbers (astronomical distances), ints are preferable.





That being said, the j = i % 2 could be the line causing the error. Using a mod operator (%) on a floating point value is a dubious operation, if it's even legal.





Hope that helps.





Edit: Just checked with Visual C++ Help system: "The operands of the remainder operator (%) must be integral. " This was the Standard C++ definition.





Edit in response to Additional Details: How do you get out of the innermost while loop? Look carefully at it.
Reply:No, actually, don't listen to Jeff G. Istream's operator%26gt;%26gt; is overloaded to many cases.





And by the way, i is never modified in the while loop. Do you see any i= or i%26lt;something%26gt;= in your while loop?





EDIT: Your do...while loop is also infinite because ans is never modified. You may want a cin%26gt;%26gt;ans just before the while line (not the one in the middle, the one at the end).





EDIT: Uhhhhhhhhhhhh...


I think your whole conversion process may be flawed. If I may, let me try to replace that internal while:





//Oh,. and set power to the highest power you want printed out.





while(i%26gt;0%26amp;%26amp;power%26gt;=0){ //FAILSAFE-no infinite loops because power is always decreased.


while(i%26gt;pow(j, power)){ //Increases the digit every time.


bin+=pow(10, power); //Inc this digit


i-=pow(j,power); //Take this out of the sum


}


}





//We SHOULD get here with power==0, if power


//is -1, a logic error occured and the while was terminated on


//the second term.





cout%26lt;%26lt;bin%26lt;%26lt;(power==-1?"LOGIC ERROR\n":"\n");


How compiler will knows the length of the array using free() function in turbo c?

the memory allocated using malloc function in free() function we will give only starting address

How compiler will knows the length of the array using free() function in turbo c?
When you allocate a memory block using malloc, you pass the amount of memory you want to reserve. If you want to allocate enough memory for a 1000 character array you would use





int *p = malloc(sizeof(char)*1000);





when you later use the free(p) function, it deallocates the entire memory block you originally allocated, regardless of the contents of that 1000 character block. So if your array exceeds 1000 characters, only the first 1000 character blocks are freed. The exceeded portion is NOT deallocated (and your program may crash since it is overwriting other sections of memory). If your array is less than 1000 character blocks, free still deallocates the amount you originally specified with malloc.

elephant ear

Templates using C++ for a function minimum. The inside the brackets formula, mine is not any good.Thanks.?

You had a number of errors and I won't remember them all so do a diff (compare) on your code with this. Basically





- you were not making function calls


- you were not using ?: syntax correctly


- your template was not returning the value


- your template names conflicted with std::max and std::min


- main() wouldn't compile





#include %26lt;iostream%26gt;


#include %26lt;string%26gt;


using namespace std;





template %26lt;class T%26gt;


T Min(T num1, T num2)


{


return((num1 %26lt; num2) ? num1 : num2);


}





//Template definition for Max function.


template %26lt;class T%26gt;


T Max(T num1, T num2)


{


return((num1 %26gt; num2) ? num1 : num2);


}








int main()


{


int i1;


int i2;


double d1;


double d2;





cout %26lt;%26lt; "Enter 2 integers: ";


cin %26gt;%26gt; i1 %26gt;%26gt; i2;


cout %26lt;%26lt; "The lesser of the two numbers is: " %26lt;%26lt; Min(i1, i2) %26lt;%26lt; endl;








cout %26lt;%26lt; "Enter 2 doubles: ";


cin %26gt;%26gt; d1 %26gt;%26gt; d2;


cout %26lt;%26lt; "The lesser of the two numbers is: " %26lt;%26lt; Min(d1, d2) %26lt;%26lt; endl;





cout %26lt;%26lt; "Enter 2 integers: ";


cin %26gt;%26gt; i1 %26gt;%26gt; i2;


cout %26lt;%26lt; "The greater number is: " %26lt;%26lt; Max(i1, i2) %26lt;%26lt; endl;








cout %26lt;%26lt; "Enter 2 doubles: ";


cin %26gt;%26gt; d1 %26gt;%26gt; d2;


cout %26lt;%26lt; "The greater number is: " %26lt;%26lt; Max(d1, d2) %26lt;%26lt; endl;





return 0;


}

Templates using C++ for a function minimum. The inside the brackets formula, mine is not any good.Thanks.?
I'm afraid you'll have to give a lot more information before anyone can begin to help you. Maybe if you posted some code examples.


HELP NEEDED IN C++ URGENTlY....can u remove files from the foll function...its plzzzzzzzzzzzz?

void function (int len0,int x,int y,int xt,int yt,int xf, int yf,


int px[],int py[],long int speed,char a[],char status,


player cur){FILE *fil;player tp;


//


if( (fil=fopen("topscore.doc","r") )==NULL )


{


fil=fopen("topscore.doc","w");


fprintf(fil,"Amit Bhola\n%d",100);


fclose(fil);


}else fclose(fil);


fil=fopen("topscore.doc","r");


fscanf(fil," %[^\n]",%26amp;tp.name);


fscanf(fil,"%d",%26amp;tp.score);


fclose(fil);


//


for(int j=1;j%26lt;len;j++)


{ px[j-1]=px[j]; py[j-1]=py[j]; }


px[len-1]=xt; py[len-1]=yt;


waitfor(speed);


gotoxy(x,y); cout%26lt;%26lt;" ";


textcolor(LIGHTGREEN);


for(int i=0;i%26lt;len;i++)


{ gotoxy(px[i],py[i]); cprintf("%c",a[i]); }


textcolor(LIGHTRED);


gotoxy(xf,yf); cprintf("O");


textcolor(LIGHTCYAN);


gotoxy(1,1);


cur.score=(len-len0)*10;


if(cur.score%26gt;=tp.score) tp=cur;


cprintf("A N A C O N D A Top Score : %15s : %d ",tp.name,tp.score);


printf("\n");


cprintf("Press esc to EXIT Player : %15s : %d ",cur.name,cur.score);


fil=fopen("topscore.doc","w");


fprintf(fil,"%s\n%d",tp.name,tp.score);


fclose(fil);


return;

HELP NEEDED IN C++ URGENTlY....can u remove files from the foll function...its plzzzzzzzzzzzz?
That's lot of work, you may contact a C++ expert at website like http://askexpert.info/
Reply:omg , wht the heck is that ???????





wht is the point of ur question, be more clear and i'll help u as well as i can. i promise i'll do my best to help , but give an understandable question.


lol


This is a joint PDF question. (c) Draw up a table showing the joint probability function Px,y(x,y) of X and Y.

a random variable Y has probability function P(Y=2)= 0.6, P(Y=3)=0.2 and P(Y=4)=0.2.


once Y has been observed, Y fair coins are tossed; let X denote the number of heads which are observed.





(a) Write downt the conditional expectation of X given Y= y, for each y=2,3,4.


hence express E[X l Y] as a function of Y.


(b) Find E(Y) and use this to calculate E(X).


(c) Draw up a table showing the joint probability function Px,y(x,y) of X and Y.


(d) find the marginal probability function of X and verify that the expectation of this distribution agrees with the value calculated in (b)

This is a joint PDF question. (c) Draw up a table showing the joint probability function Px,y(x,y) of X and Y.
.. X ....... 0 ................. 1 ................ 2 ................ 3 ............... 4


Y=2 . (.25)(.6) ...... (.5)(.6) ........ (.25)(.6) ............ 0 .............. 0


3 .... (.125)(.2) .... (.375)(.2) ...... (.375)(.2) ..... (.125)(.2) ...... 0


4 ... (.0625)(.2) ..... (.25)(.2) ... (.375)(.2) . (.25)(.2) . (.0625)(.2)








If y = 2, 0 head: 1/4 , 1 head: 2/4, 2 heads: 1/4 (then multiply 0.6)





If y = 3, 0 H: 1/8 , 1H: 3/8 , 2H: 3/8 , 3H: 1/8





If y = 4: 0H: 1/16, 1H: 4/16 , 2H: 6/16 3H: 4/16 4H: 1/16





Also, E[Y] = 2*.6 + 3*.2 + 4*.2 = 2.6


I had now given you the table. Multiply to get the values and use that to determine the rest of the answers. ©
Reply:a)





E[X|Y=2] = 0.5*2 = 1


E[X|Y=3] = 0.5*3 = 1.5


E[X|Y=4] = 0.5*4 = 2


E[X|Y=y] = 0.5*y





b)





E[Y] = 2*0.6 + 3*0.2 + 4*0.2 = 2.6





E[X] = E[ E[ X|Y ] ] = Sum over all y of E[X|Y=y]P[Y=y]


= 1 * 0.6 + 1.5 * 0.2 + 2 * 0.2 = 1.3





c)


These are all found using the binomial distribution and mulitplied by P[Y=y]





Y = y | 2_________3___________4_______total P[X= x]





X = 0 | 0.25*0.6____0.125*0.2____0.0625*0.2


X = 1 | 0.5*0.6_____0.375*0.2____0.25*0.2


X = 2 | 0.25*0.6____0.375*0.2_____0.375*0.2


X = 3 | 0_________0.125*0.2_____0.25*0.2


X = 4 | 0_________0___________0.0625*0.2





total P[Y=y]





to finish the table sum the columns to get P[Y=y] and sum the rows for P[X=x]


What does c++ pure virtual function call mean on your desktop?

Unless you're planning to debug the program yourself, it pretty much means there's a glitch in your software. Try checking for an update online for both the program and your computer. Make sure you have the latest version of .NET as well. Link is to .NET 2.0 redist.

lady palm

Write a program in c for printf function instead of using printf library function?

I faced this questiuon in hoiney well plz reply anybody

Write a program in c for printf function instead of using printf library function?
#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;





void main()


{


char a[6]={'t', 'a', 'n', 'v', 'e', 'e', 'r'};


int i;


i=0;


while(a[i]!='\o')


{


putchar(a[i]);


}


i++;


getch();


}











compare this with the above program which is without printf function.








void main()


{


printf("tanveer");


getch();


}











Hope this will give you some idea or reference. The question is not asked specific to any integer printing or charter printing.


I have used character printing.
Reply:you can implement the printf() clone in many ways..


One way is to use putchar() method...


now you'll be wondering how to pass random number of arguments to our new function (let it be named myprint())..





In C we can write functions which takes multiple number of arguments...


how??





int myprint(int itemsToPrint, char [] type,...)





So now prototype is done..





We now just need to resolve the arguments which are to be printed.. For this we need to use few macros provided by most of the C implementations..


Using these macros we can access the arguments passed to our new function(i don't remember there name properly...)


Even printf/scanf uses those macro calls..


In our function first argument is the number of arguments to be printed.. Second argument is a character array which must contain the type of arguments which are to be printed in the order of appearance in the function call...





now if you are to print a character / character string using putchar is easy....


if you are about to print a float/int etc.. then convert them to character array and use puthar to print individual characters ...


What is the objective function for the following story problem? a,b,c, or d?

What is the objective function for the following story problem?


A company has two skill levels of production workers, level I and level II.


A level I worker is paid $8.00 per hour, and produces 12 items per hour.


A level II worker is paid $14.00 per hour and produces 21 items per hour.


The company is required to use at least 2500 employee hours per week.


The company must produce at least 45,000 items per week.


How many hours per week should the company use workers in each skill level in order to minimize labor costs?








a) z = 8x + 14y


b) z = 4x + 8y


c) z = 14x + 8y


d) z = 4x + 7y

What is the objective function for the following story problem? a,b,c, or d?
You want to minimize labor costs, so that's what you need to look at.


Level 1 costs 8 per hour.


Level 2 costs 14 per hour.





Depending on what you want x and y to represent, the answer is either z = 8x + 14y or z = 14x + 8y


If x = number of hours a level 1 worker works and y = number of hours a level 2 worker works, then z = 8x +14y is correct.





You could also say x = number of hours a level 2 worker works and y = number of hours a level 1 worker works, then z = 14x +8y is correct.


In C#.net which function is used to find the value of a string.?

use atoi(char) to convert char to int.


use atol(char) to convert char to long.


use atof(char) to convert char to float.

In C#.net which function is used to find the value of a string.?
strlen


Reg c:write a function that interchange two values without temp variable?

swap(a,b)

Reg c:write a function that interchange two values without temp variable?
swap(a,b) is not a standard C function, it is a standard C++ function. The question asks about writing are own code for swap(a,b) anyway:





#include %26lt;stdio.h%26gt;





int a = 7;


int b = 23;


/* C uses call-by-value by default */


void swap(int x, int y)


{


a = y;


b = x;


}





int main()


{


printf("a= %d\n",a);


printf("b=%d\n",b);





swap(a,b);





printf("a= %d\n",a);


printf("b=%d\n",b);





return 0;


}





(how do you save indentation when you post here?)





Edit: I like mashiur1973's answer below but keep in mind, the a and b inside swap won't exist outside of the swap function unless you use global variables (like I did) which is usually bad practice or if you use pointers and references like this:





#include %26lt;stdio.h%26gt;





void swap(int *a, int *b)


{


*a = *a + *b;


*b = *a - *b;


*a = *a - *b;


}





int main()


{


int a = 2;


int b = 3;





printf("a= %d\n",a);


printf("b= %d\n",b);





swap(%26amp;a,%26amp;b);





printf("a= %d\n",a);


printf("b= %d\n",b);





return 0;


}
Reply:I think you can use the following:-





void swap(int a, int b)


{


a = a + b;


b = a - b;


a = a - b;


}





Let's analyze the function:-


considering a = 2, b = 3, we call the function


swap(a,b);





Stmt 1: a = a + b;


new value of 'a' would be = 2 + 3 = 5;





Stmt 2: b = a - b;


new value of 'b' would be = 5 - 3 = 2;





Stmt 3: a = a - b;


new value of 'a' would be = 5 - 2 = 3;





Hence at the end we have a = 3 and b = 2;

snow of june

Find an exponential function of the form f(x)=ab^kx +c with b not equal to 1 a not 0 k not 0 that goes through

find an exponential function of the form f(x)=ab^kx +c with b not equal to 1 a not 0 k not 0 that goes through the points (2,0) (5,0) (8,0). Make sure to write your answer in the specified form in your final answer

Find an exponential function of the form f(x)=ab^kx +c with b not equal to 1 a not 0 k not 0 that goes through
Come on now, What have I always told you in class- NO CHEATING! Do your own homework!
Reply:The question may be stated erroneously. As stated the function is not dependant on x at all. The equation y=0 is a line through all the points.


Let f:C-C be continuous function.If f^2,f^3 be analytic show f is analytic?

note that f^3/f^2 = f except for the points where f(z) = 0 (thos will be singularities). But you can show that those singularities are removable (that will be your job - just remember that the order of the zero of f^3 will be larger than the order of the zero of f^2...) Since they are removable, you can extend this to an entire function. But, this function must be f, since they agree on a set with a limit point (namely, the set of f(z) s.t f(z) is not zero)... We should note that none of this will work if f is constant, but the constant case should be easy, right?

Let f:C-C be continuous function.If f^2,f^3 be analytic show f is analytic?
Divide. Around zeros, use the fact that square roots are multiply defined.


Find an exponential function of the form f(x)=ab^kx +c?

Find an exponential function of the form f(x)=ab^kx +c with b not equal to 1 a not 0 k not 0 that goes through the points (2,0) (5,0) (8,0). Make sure to write your answer in the specified form in your final answer

Find an exponential function of the form f(x)=ab^kx +c?
Pass.
Reply:that's not possible - exponential function has to be either increasing or decreasing, so it canot have same value at 3 different points





moreover, you can find infintely many pairs of b and k that would give you exactly the same function.
Reply:f(x)=ab^kx +c


(2,0) gives 0 = ab^2k + c


The other two points give two more equations.


Then you have 3 equations and 4 unknowns.


That cannot be solved.





(2 , 0) gives 0 = ab^2k + c @


(5 , 0) gives 0 = ab^5k + c $


(5 , 0) gives 0 = ab^5k + c %26amp;





@ - $ gives ab^2k = ab^5k. So 2k=5k So k=0 and that is unwished.


So again: no solution.





See also intel nite above
Reply:I would guess that something is wrong with the question. The points all lie on the x axis i.e. y = 0. The function is not dependent on x at all
Reply:look the simplest answer is y=0 ;


but to put it in exponential form look at this


a=1 b=e , k= - infinity ,c = 0.


which means y=e^(- infinity * x )+ 0


anything * - infinity = - infinity


y= e ^( - infinity )


e^(- infinity) = 0


y= 0





THIS WILL NOT WORK IF THE SOLUTION REQUIRES ALL NUMBERS TO BE REAL .
Reply:a=10


b=0


k=5


c=0


(the point here is that if b not equal to 1 a not 0 k not 0


then b must = 0, then c=0 and a,k can be anything)





f(x) = 10(0^5x) + 0





This function equals 0 for all x%26gt;0


(Note that f(0)=10 however, so this function is not equivalent to


f(x) = 0 !! f is not defined for x%26lt;0, but we dont need it to be.)





Note to Thermo:





In your proof, when you get to:


ab^2k = ab^5k. (this implies b^2k=b^5k or a=0. but a=0 is prohibited)


So 2k=5k


So k=0.


This does not necessarily follow, as you forgot to include the cases:





b=1 or b=0. 1^x = 1 for all x and 0^x = 0 (x%26gt;0)





Since b=0 is the only case not precluded from the question, it is the only solution. Therefore c must be 0 and a and k can be anything as I described.





For the rest of you who say no solution possible, didnt you read my counterexample to your belief?





Again, a=10,b=0,k=5,c=0 IS A SOLUTION TO THE QUESTION AS WRITTEN