Friday, July 31, 2009

Write a non-recursive function in 'C' Programming language to reverse a doubly linked list.?

Go to the end of the list.





While node-%26gt;prev != NULL


{


print value


node = node-%26gt;prev


}

Write a non-recursive function in 'C' Programming language to reverse a doubly linked list.?
Here is an example:





#include %26lt;stdio.h%26gt; /* for printf */


#include %26lt;stdlib.h%26gt; /* for malloc */





typedef struct ns {


int data;


struct ns *next;


} node;





node *list_add(node **p, int i) {


/* some compilers don't require a cast of return value for malloc */


node *n = (node *)malloc(sizeof(node));


if (n == NULL)


return NULL;


n-%26gt;next = *p;


*p = n;


n-%26gt;data = i;


return *p;


}





void list_remove(node **p) { /* remove head */


if (*p != NULL) {


node *n = *p;


*p = (*p)-%26gt;next;


free(n);


}


}





node **list_search(node **n, int i) {


while (*n != NULL) {


if ((*n)-%26gt;data == i) {


return n;


}


n = %26amp;(*n)-%26gt;next;


}


return NULL;


}





void list_print(node *n) {


if (n == NULL) {


printf("list is empty\n");


}


while (n != NULL) {


printf("print %p %p %d\n", n, n-%26gt;next, n-%26gt;data);


n = n-%26gt;next;


}


}





int main(void) {


node *n = NULL;





list_add(%26amp;n, 0); /* list: 0 */


list_add(%26amp;n, 1); /* list: 1 0 */


list_add(%26amp;n, 2); /* list: 2 1 0 */


list_add(%26amp;n, 3); /* list: 3 2 1 0 */


list_add(%26amp;n, 4); /* list: 4 3 2 1 0 */


list_print(n);


list_remove(%26amp;n); /* remove first (4) */


list_remove(%26amp;n-%26gt;next); /* remove new second (2) */


list_remove(list_search(%26amp;n, 1)); /* remove cell containing 1 (first) */


list_remove(%26amp;n-%26gt;next); /* remove second to last node (0) */


list_remove(%26amp;n); /* remove last (3) */


list_print(n);





return 0;


}


What does the VOID function in c++ do?

In a strict, arguably pedantic way, everyone here is wrong.





A void function returns *type* void but since functions return values, not types, nothing is returned. However there are some curious uses, mostly involving templates, where there are some applications.





Just to blow some minds:





#include %26lt;iostream%26gt;





using namespace std;








void foo()


{


cout %26lt;%26lt; "hello world\n";


}








void bar()


{


return foo();


}








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


{


bar();


}





Didn't expect that to compile and work, did ya?

What does the VOID function in c++ do?
David has part of the answer....in fact not only is void used to signify that you are not going to return a value but it can also (and is done commonly) be used as a way to signify a incoming/outgoing value (thru: void *) that has no defined type at runtime...think of it as a generic intrinsic type that when you do decide to use its value you will explicitly cast this void* type to whatever you like.
Reply:Nothing, that why it is void. If you look at a language like Pascal, which has functions (snippets of code that return a value) and subroutines (code that doesn't return anything) there is no void type. The first thing in a function header is a return type, since C++ only has functions to specify you aren't returning a value you put the void keyword.


eg.


int x = mymathfunction(); // fine if mymathfunction returns int,


error if the return type is void.





void is can also be used in a parameter list that takes nothing. eg.


void printmenu(void)


{ //code


}








In case you are wondering why main has a return type in C++, it is because it returns an integer value to the operating system.
Reply:void just means that the function does not return a value. If the function is just used to perform some action but does not need to return a status it is declared as void.


How to write a function in C program, that reads as many lines the user wants until the user says NO?

Split the lines into words. If the word contains only alphabtes, then it is a proper word. If contains special characters or numbers it is improper word. The output should be "No of Lines", "No of proper words", "No of improper words". Plz solve this problem

How to write a function in C program, that reads as many lines the user wants until the user says NO?
We're approaching the end of the semester so you should be able to do your own homework by now. If you have specific questions about the code, or if you write it and have problems you can't solve, I'd be happy to answer. As it is you're not asking a question but rather you're demanding we do your homework for you.


Determine the marginal cost function for c(x)=x^3-6x^2+1?

It's the derivative:


c'(x)=3x^2-12x

Determine the marginal cost function for c(x)=x^3-6x^2+1?
If c(x) is the cost function then the marginal cost function would be the first derivative of that.





dc/dx=3x^2-12x
Reply:derivative





C'(x)= 3x²-12x

kudzu

I m using 'log' function in C++, do I need a special lib?

case 9:


if (lb!=0)


{


lc = log(lb);


}


break;

I m using 'log' function in C++, do I need a special lib?
log


%26lt;math.h%26gt;





double log ( double x );





Calculate natural logarithm.


Returns the natural logarithm of parameter x.





Parameters.





x


Floating point value.





Return Value.


Logarithm of x.





Portability.


Defined in ANSI-C.


ANSI-C++ adds float and double overloaded versions of this function, with the same bahavior but being both, parameter and result, of one of these types.





Example.





/* log example */


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


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





int main ()


{


double param, result;


param = 5.5;


result = log (param);


printf ("ln(%lf) = %lf\n", param, result );


return 0;


}





Output:


ln(5.500000) = 1.704748
Reply:yes, include the line below in your source code:


#include%26lt;math.h%26gt;
Reply:You code module needs to #include %26lt;math.h%26gt; to get the function prototype for the log function. You will also need to ensure the compiled object module is linked with the math library (libm.a). In a UNIX environment put a -lm argument on the linker command.


What are types of function in c programming?

I dont know the exact name called function but i know the concept:





1. pass-by reference





it is a function made using different variables to call the function





e.g:


void name (%26amp;int a)


...


...


name(x);








2.pass-by value same variable





e.g:


void name (%26amp;int a)


...


...


name(a);





3. under main function


this function are made after the main





main()


{


...


...


}


void name(int a)


{


}








this are my ideas about function


goodluck

What are types of function in c programming?
Computer Tutorials, Interview Question And Answer


http://freshbloger.com/


Is there any library function in C++ which could clear the run screen?

if you are talking about plain old c++ programming, I guess the conio.h has a funcition to clear the screen;





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


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





void main()


{


clrscr();





}





i guess this works.

Is there any library function in C++ which could clear the run screen?
What you see below are the nest of functions that you can use on your key board for short cuts. Copy and paste this and save it for future refrence.





Tech Tips on Windows Keyboard Shortcuts for V6.0, and updated with all NEW shortcuts for Internet Explorer v7.0.





Borrowing from Firefox and other browsers, IE7 now features tabbed-browsing. With tabbed-browsing you can, among other things:





Use one Internet Explorer window to view all your web pages.


Open links in a background tab while viewing the page you're on.


Save and open multiple web pages at once by using favorites


and home page tabs.





Most people think they know the ins and outs of using their favorite software (and maybe they do), but there are hundreds of little shortcuts that can be used to make common tasks even easier. This Tech Tip is going to follow a different format than the norm and will list a few dozen of these hot keys that can be used to make working in Microsoft Windows even easier.





The shortcuts covered are broken up into groups based on the main key involved in activating them. So, let’s take a look at what we can do with the ALT, CTRL, SHIFT, and Windows Keys, as well as a few combo moves…





General Keyboard Shortcuts:


CTRL+C (Copy)


CTRL+X (Cut)


CTRL+V (Paste)


CTRL+Z (Undo)


DELETE (Delete)


SHIFT+DELETE (Delete the selected item permanently without placing the item in the Recycle Bin)


CTRL while dragging an item (Copy the selected item)


CTRL+SHIFT while dragging an item (Create a shortcut to the selected item)


F2 key (Rename the selected item)


CTRL+RIGHT ARROW (Move the insertion point to the beginning of the next word)


CTRL+LEFT ARROW (Move the insertion point to the beginning of the previous word)


CTRL+DOWN ARROW (Move the insertion point to the beginning of the next paragraph)


CTRL+UP ARROW (Move the insertion point to the beginning of the previous paragraph)


CTRL+SHIFT with any of the arrow keys (Highlight a block of text)


SHIFT with any of the arrow keys (Select more than one item in a window or on the desktop, or select text in a document)


CTRL+A (Select all) F3 key (Search for a file or a folder)


ALT+ENTER (View the properties for the selected item)


ALT+F4 (Close the active item, or quit the active program)


ALT+ENTER (Display the properties of the selected object)


ALT+SPACEBAR (Open the shortcut menu for the active window)


CTRL+F4 (Close the active document in programs that enable you to have multiple documents open simultaneously)


ALT+TAB (Switch between the open items)


ALT+ESC (Cycle through items in the order that they had been opened)


F6 key (Cycle through the screen elements in a window or on the desktop)


F4 key (Display the Address bar list in My Computer or Windows Explorer)


SHIFT+F10 (Display the shortcut menu for the selected item)


ALT+SPACEBAR (Display the System menu for the active window)


CTRL+ESC (Display the Start menu)


ALT+Underlined letter in a menu name (Display the corresponding menu)


Underlined letter in a command name on an open menu (Perform the corresponding command)


F10 key (Activate the menu bar in the active program)


RIGHT ARROW (Open the next menu to the right, or open a submenu)


LEFT ARROW (Open the next menu to the left, or close a submenu)


F5 key (Update the active window)


BACKSPACE (View the folder one level up in My Computer or Windows Explorer)


ESC (Cancel the current task)


SHIFT when you insert a CD-ROM into the CD-ROM drive (Prevent the CD-ROM from automatically playing)








Microsoft Internet Explorer 7.0 Keyboard Shortcuts:


CTRL+click (Open links in a new tab in the background)


CTRL+SHIFT+click (Open links in a new tab in the foreground)


CTRL+T (Open a new tab in the foreground)


ALT+ENTER (Open a new tab from the Address bar)


ALT+ENTER (Open a new tab from the search box)


CTRL+Q (Open Quick Tabs - thumbnail view)


CTRL+TAB/CTRL+SHIFT+TAB (Switch between tabs)


CTRL+n (n can be 1-8) (Switch to a specific tab number)


CTRL+9 (Switch to the last tab)


CTRL+W (Close current tab)


ALT+F4 (Close all tabs)


CTRL+ALT+F4 (Close other tabs)


For more information, visit: http://www.microsoft.com





Dialog Box Keyboard Shortcuts:





If you press SHIFT+F8 in extended selection list boxes, you enable extended selection mode. In this mode, you can use an arrow key to move a cursor without changing the selection. You can press CTRL+SPACEBAR or SHIFT+SPACEBAR to adjust the selection. To cancel extended selection mode, press SHIFT+F8 again. Extended selection mode cancels itself when you move the focus to another control.





CTRL+TAB (Move forward through the tabs)


CTRL+SHIFT+TAB (Move backward through the tabs)


TAB (Move forward through the options)


SHIFT+TAB (Move backward through the options)


ALT+Underlined letter (Perform the corresponding command or select the corresponding option)


ENTER (Perform the command for the active option or button)


SPACEBAR (Select or clear the check box if the active option is a check box)


Arrow keys (Select a button if the active option is a group of option buttons)


F1 key (Display Help)


F4 key (Display the items in the active list)


BACKSPACE (Open a folder one level up if a folder is selected in the Save As or Open dialog box)





Windows Explorer Keyboard Shortcuts:





END (Display the bottom of the active window)


HOME (Display the top of the active window)


NUM LOCK+Asterisk sign (*) (Display all of the subfolders that are under the selected folder)


NUM LOCK+Plus sign (+) (Display the contents of the selected folder)


NUM LOCK+Minus sign (-) (Collapse the selected folder)


LEFT ARROW (Collapse the current selection if it is expanded, or select the parent folder)


RIGHT ARROW (Display the current selection if it is collapsed, or select the first subfolder)





Microsoft Natural Keyboard Shortcuts:





Windows Logo (Display or hide the Start menu)


Windows Logo+BREAK (Display the System Properties dialog box)


Windows Logo+D (Display the desktop)


Windows Logo+M (Minimize all of the windows)


Windows Logo+SHIFT+M (Restore the minimized windows)


Windows Logo+E (Open My Computer)


Windows Logo+F (Search for a file or a folder)


CTRL+Windows Logo+F (Search for computers)


Windows Logo+F1 (Display Windows Help)


Windows Logo+ L (Lock the keyboard)


Windows Logo+R (Open the Run dialog box)


Windows Logo+U (Open Utility Manager)





Accessibility Keyboard Shortcuts:





Right SHIFT for eight seconds (Switch FilterKeys either on or off)


Left ALT+left SHIFT+PRINT SCREEN (Switch High Contrast either on or off)


Left ALT+left SHIFT+NUM LOCK (Switch the MouseKeys either on or off)


SHIFT five times (Switch the StickyKeys either on or off)


NUM LOCK for five seconds (Switch the ToggleKeys either on or off)


Windows Logo +U (Open Utility Manager)





Remote Desktop Connection Navigation:





CTRL+ALT+END (Open the Microsoft Windows NT Security dialog box)


ALT+PAGE UP (Switch between programs from left to right)


ALT+PAGE DOWN (Switch between programs from right to left)


ALT+INSERT (Cycle through the programs in most recently used order)


ALT+HOME (Display the Start menu)


CTRL+ALT+BREAK (Switch the client computer between a window and a full screen)


ALT+DELETE (Display the Windows menu)


CTRL+ALT+Minus sign (-) (Place a snapshot of the entire client window area on the Terminal server clipboard and provide the same functionality as pressing ALT+PRINT SCREEN on a local computer.)


CTRL+ALT+Plus sign (+) (Place a snapshot of the active window in the client on the Terminal server clipboard and provide the same functionality as pressing PRINT SCREEN on a local computer.)





Other Information:





Some keyboard shortcuts may not work if StickyKeys is turned on in Accessibility Options.





Some of the Terminal Services client shortcuts that are similar to the shortcuts in Remote Desktop Sharing are not available when you use Remote Assistance in Windows XP Home Edition.





Final Words:


Windows hot keys are all intended to provide some sort of convenient alternative to common tasks, and whether specific combinations do so is up to the individual to decide. Some are simple time-saving motions, while others are complex maneuvers in finger gymnastics. There are dozens of other common Windows shortcuts (and even more related to specific software titles), and memorizing just a few of the more basic ones may be worth the time-savings they can afford you.





Good luck and we hope this will help you now as well as in the futire.


What is the fibonacci function in c programming?

the fibonacci sequence is the first number, beginning with 1 and adding the previous number.


ie: 1 1 2 3 5 8 ...


1


1 + 1 = 2


1 + 2 = 3


2 + 3 = 5


3 + 5 = 8...

What is the fibonacci function in c programming?
long fib_num(long n)


{


long low(0), high(1);





while (n--) {


high += low;


low = high - low;


}





return low;

garland flower

How to use string function in C?

There is no string function you have to use character arrays.





RJ

How to use string function in C?
This depends on what you are trying to do.


You must include strng.h at the top of your file e.g.


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





A string is a null terminated char array e.g.


char mystr[80] = "Hello World";


/* mystr is = "Hello World\0" */


mystr[5] = '\0'; /* Null terminated so the string is now Hello*/





Look here http://www.opengroup.org/onlinepubs/0079... for explanations of the functions but basicall you use them like:-





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





void main(void) {


char str1[80] = "A String";


char str2[80] = "Another String";





if (strcmp(str1, str2) == 0)


printf ("They are the same\n");


else


printf ("They are different\n");





if (strncmp(str1, str2, 1) == 0)


printf ("The first character is the same\n");


else


printf ("The first character is different\n");





}
Reply:There is no string datatype in C, but there are several functions that work with "strings" (arrays of characters with a null terminator). For example, strcmp, strncmp, strcpy, etc.





Are you referring to these?


What is the difference between function returning pointer,function pointer & pointer to function in C lang??

A function that returns a pointer returns a reference to a memory address. A function that returns a pointer should NOT define the pointer or it will disappear when the function goes out of scope. A lot of times the pointer is passed into the function as a parameter, modified and returned.





A prototype for a function that returns a pointer looks like:


aPtr * funcReturnsPtr( SomeType * aPtr);





A function pointer is a pointer that points to the address of a function. That variable is a pointer to a function.


Here's an example of a variable pointing to a function:


float result = pt2Func(a, b);

What is the difference between function returning pointer,function pointer %26amp; pointer to function in C lang??
function returning pointer returns pointer value.


function pointers are pointer variables having its value pointing to the address of any function.


pointers to function means that the arguments passed in the function are pointers.
Reply:char *Function1()


{


return "Hello";


}


char *Function2()


{


return "World";


}





char * ((*function_pointer)());





main()


{


function_pointer = Function1;


printf("%s ", (*function_pointer)());


function_pointer = Function2;


printf("%s\n", (*function_pointer)());


}








-----------------------


In the above example Function1 and Function2 return pointers. function_pointer is a pointer to a function that returns a character. The output of the above program is


Hello World.





A function pointer is a pointer to a function.


If the consumption function is C=100+0.8(Y-T), the government purchases multiper is 5. I want to ask why ?

It is about economics.AGGREGATE DEMAND

If the consumption function is C=100+0.8(Y-T), the government purchases multiper is 5. I want to ask why ?
The multiplier for government spending also depends on a range of other factors, such as how much goes into imports etc. However, I have assumed that you have a closed economy (no imprts or exports and no need for an exchange rate) and that if the government increases its spending, it doesn't need to raise taxes at some point in the future to balance its budget.





If you make these assumptions, you can get a multiplier of 5. Suppose the government spends an additional 1 unit on services so that it all goes into household incomes (ie so that Y increases by 1), the first round effect is to add 0.8 to C. If all of this goes into incomes and increases Y by a further 0.8, the second round impact is to increase C by a further 0.64, with the third and subsequent rounds' impacts each being 80% of the previous rounds impact.





The total impact will be 1+0.8+(0.8)(0.8)+(0.8)(0.8)(0.8)+(0.8)(0...


Using some mathematical manipulation you can prove this equals 5. Alternatively, use a spreadsheet starting with 1, and then each row underneath it multiplied by 0.8 to get the first 20 or so terms and then sum them up and you can verify this without having to do any algebra.


What is the function in c language to delete a line from text file??

There is no such function in the standard C library.





Open the file for reading


Open an output file for writing.


Read the first file, line at a time. If it's not the line you want to delete, write the line to the output file.


Close both files.


Change the name of the first file to something else.


Change the name of the second file to the original name of the first file.


Then and ONLY then is it safe to delete the original file.

blazing star

Help!! Urgent.. Print function in C#. . .?

I am doing a website. I have a button that allow the user to click and print out that partipular webpage (the page with the print button). Anyone know how to do??





Thanks Alot in advance..

Help!! Urgent.. Print function in C#. . .?
%26lt;input type="button" value="Print" onclick="window.print()" id=button1 name=button1%26gt;





Please note that this will not work in all browsers


I want a function in c++ that returns available memory.?

for example i get this memory:





int* p=new[100000];





i want to see the available memory befor and after it.

I want a function in c++ that returns available memory.?
For 32 bit Windows:





DWORD ramsize;


DWORD freesize;


MEMORYSTATUS lpBuffer;





lpBuffer.dwLength = sizeof(MEMORYSTATUS);





GlobalMemoryStatus(%26amp;lpBuffer);


ramsize = lpBuffer.dwTotalPhys;


freesize = lpBuffer.dwAvailPhys;
Reply:There is no such native function in c++; it depends on the OS. You need to look in the Linux or Windows documentation for a suitable function. BTW, even if such a function were available, you *might* not get the result you're looking for. Typically an OS might maintain a memory pool on a per-process basis to speed memory allocation. So you might find that the available memory is unchanged after your new[] call.


Wat is virtual function in c++?

C++ virtual function is a member function of a class, whose functionality can be over-ridden in its derived classes. The whole function body can be replaced with a new set of implementation in the derived class. The concept of c++ virtual functions is different from C++ Function overloading.





C++ Virtual Function - Properties:


C++ virtual function is,





A member function of a class


Declared with virtual keyword


Usually has a different functionality in the derived class


A function call is resolved at run-time


The difference between a non-virtual c++ member function and a virtual member function is, the non-virtual member functions are resolved at compile time. This mechanism is called static binding. Where as the c++ virtual member functions are resolved during run-time. This mechanism is known as dynamic binding.














C++ Virtual Function - Reasons:


The most prominent reason why a C++ virtual function will be used is to have a different functionality in the derived class.





For example a Create function in a class Window may have to create a window with white background. But a class called CommandButton derived or inherited from Window, may have to use a gray background and write a caption on the center. The Create function for CommandButton now should have a functionality different from the one at the class called Window.





C++ Virtual function - Example:


This article assumes a base class named Window with a virtual member function named Create. The derived class name will be CommandButton, with our over ridden function Create.





class Window // Base class for C++ virtual function example


{


public:


virtual void Create() // virtual function for C++ virtual function example


{


cout %26lt;%26lt;"Base class Window"%26lt;%26lt;endl;


}


};





class CommandButton : public Window


{


public:


void Create()


{


cout%26lt;%26lt;"Derived class Command Button - Overridden C++ virtual function"%26lt;%26lt;endl;


}


};





void main()


{


Window *x, *y;





x = new Window();


x-%26gt;Create();





y = new CommandButton();


y-%26gt;Create();


}





The output of the above program will be,


Base class Window


Derived class Command Button





If the function had not been declared virtual, then the base class function would have been called all the times. Because, the function address would have been statically bound during compile time. But now, as the function is declared virtual it is a candidate for run-time linking and the derived class function is being invoked.





C++ Virtual function - Call Mechanism:


Whenever a program has a C++ virtual function declared, a v-table is constructed for the class. The v-table consists of addresses to the virtual functions for classes and pointers to the functions from each of the objects of the derived class. Whenever there is a function call made to the c++ virtual function, the v-table is used to resolve to the function address. This is how the Dynamic binding happens during a virtual function call.

Wat is virtual function in c++?
A virtual function is a member function of a class that, when redefined by a derived class, behaves in a special way. When you use polymorphism, and point to a derived object using a base class pointer, then call that base class pointer's virtual member function, the program will actually execute the derived class's version of the function.





ex:


class base {


public:


virtual int foo() return 0;


}


class derived : base {


public:


virtual int foo() return 1;


}





int main() {


base* myBasePointer = new derived;


cout%26lt;%26lt;myBasePointer-%26gt;foo();


}





will print out "1" instead of "0"
Reply:C++ virtual function is a member function of a class, whose functionality can be over-ridden in its derived classes. The whole function body can be replaced with a new set of implementation in the derived class. The concept of c++ virtual functions is different from C++ Function overloading.


C++ Virtual Function - Properties:





C++ virtual function is,





* A member function of a class


* Declared with virtual keyword


* Usually has a different functionality in the derived class


* A function call is resolved at run-time





The difference between a non-virtual c++ member function and a virtual member function is, the non-virtual member functions are resolved at compile time. This mechanism is called static binding. Where as the c++ virtual member functions are resolved during run-time. This mechanism is known as dynamic binding.





C++ Virtual Function - Reasons:





The most prominent reason why a C++ virtual function will be used is to have a different functionality in the derived class.





For example a Create function in a class Window may have to create a window with white background. But a class called CommandButton derived or inherited from Window, may have to use a gray background and write a caption on the center. The Create function for CommandButton now should have a functionality different from the one at the class called Window.


C++ Virtual function - Example:





This article assumes a base class named Window with a virtual member function named Create. The derived class name will be CommandButton, with our over ridden function Create.





class Window // Base class for C++ virtual function example


{


public:


virtual void Create() // virtual function for C++ virtual function example


{


cout %26lt;%26lt;"Base class Window"%26lt;%26lt;endl;


}


};





class CommandButton : public Window


{


public:


void Create()


{


cout%26lt;%26lt;"Derived class Command Button - Overridden C++ virtual function"%26lt;%26lt;endl;


}


};





void main()


{


Window *x, *y;





x = new Window();


x-%26gt;Create();





y = new CommandButton();


y-%26gt;Create();


}





The output of the above program will be,


Base class Window


Derived class Command Button





If the function had not been declared virtual, then the base class function would have been called all the times. Because, the function address would have been statically bound during compile time. But now, as the function is declared virtual it is a candidate for run-time linking and the derived class function is being invoked.


C++ Virtual function - Call Mechanism:





Whenever a program has a C++ virtual function declared, a v-table is constructed for the class. The v-table consists of addresses to the virtual functions for classes and pointers to the functions from each of the objects of the derived class. Whenever there is a function call made to the c++ virtual function, the v-table is used to resolve to the function address. This is how the Dynamic binding happens during a virtual function call.











For more info. make a google search, or log on to


www.http://www.codersource.net/cpp_virtual_f...
Reply:Polymorphism: This is one of the important concepts of Object oriented programming language. The word Polymorphism is made of two words (POLY + MORPHISM) (means one thing have several form.).


Example:


‘+’ mainly used to add two integer values, but if we write its functionality to concatenate two strings, means one thing is doing two different operation.





Types of Polymorphism:


1. Static Polymorphism(Ex. Function Overloading, Operator Overloading etc)


2. Dynamic Polymorphism (virtual function)





Dynamic Polymorphism: (also called as run time polymorphism, late binding,)


Here all the need able information is provided at the run time. This can be achieved using the concept of Virtual function.(base class pointer %26amp; Inheritance)





Virtual function: A function that is defined using virtual keyword. It can be defined as redefining the base class member functions in the derived class.


Lets take an example:





Class base {





Public:


void display()


{


cout%26lt;%26lt;”this is the display function of base class”;





}





};





Class derived : public base {





Public:


Void display()


{





cout%26lt;%26lt;”this is display function of derived class”;





};





Void main()


{


Base *ptr, baseObj;


derived derivedObj;


ptr=%26amp;baseObj; // here we r providing the detail that ptr will call display


function of which class, (detail at runtime.)








ptr-%26gt;display(); // this will display function of base class.





ptr-%26gt;%26amp;derivedObj; // here we r providing the detail that ptr will call display


function of which class( detail at runtime.)





ptr-%26gt;display(); // this will call the display function of derived class.























}








}


To use pow function in C# , which namespace is to be added in the beginning?

You don't need to import anything, or adjust the namespace of your application. The pow function is a static method (as are most if not all methods in this class) of the Math class. Ex:





double result = Math.pow(5, 2);





result would equal 25. Note that the return is a double.


What do atoi function in c language do?

converts an ascii string in to a integer number

What do atoi function in c language do?
Hello


atoi stands for array to integer. It converts array(string) to integer valule.


Eg.


{


char val[4];


int res;


printf("Enter a value");


gets(val);


res = atoi(res);


printf(" Its value is %d",res);


getch();


}


Thanks


Jana.KV
Reply:atoi function is used to convert an ASCII string (charator array) to number. You can probably use it when you need to find the ascii value for a single charator or for a string.





Areas of application : can be used in encription or decription





G.Format : integer_variable = atoi(charator_array);


int=atoi(char[]);
Reply:the answer given by somebody above me is quite good........ except he made a slight error in his example -


- change the line


res = atoi(res);


- to


res = atoi(val);
Reply:its a macro that converts string to integer





for more details check ur Turbo C++ help


Help Please!consumption function is C=2500+.70Y where Y is disposable income. Y=32600. saving is = to??

how do i solve this??

Help Please!consumption function is C=2500+.70Y where Y is disposable income. Y=32600. saving is = to??
First find consumption:


C=2500+.7*(32600)


C=2500+22820=25320





Consumption + Savings is the total disposable income, so:


Y=C+S


S=Y-C=32600-25320=7280
Reply:Saving is equal to income minus consumption.





With reference to the equation, this is computed as,





Saving = Y - C


= 32600 - [2500 + .7(32600)]


= 32600 - 25320


= 7280
Reply:Method 1:(substitution)





C=2500+0.7Y


Y=32600


thus C=2500+0.7(32600)


C=2500+22820


C=25320


C+S=Y


S=32600-25320


S=7280





Method 2:(using the savings function)


Y=a+bY [a- autonomous cons; b- MPC]


S= -a+(1-b)Y


S= -2500+0.3(32600)


S=-2500+9780


S=7280

elephant ear

Is Macro concept in C language and Inline function in C++ are same?

If not what is the important difference and which one is efficent

Is Macro concept in C language and Inline function in C++ are same?
No. Macros work both in C and C++ and they are evaluated and expanded by the prepocessor before compiling. Macros are mostly a tool to make code easier to write for programmers. They don't really affect the way the program executes





Inlining functions on the otherhand is used to increase performance. You can manually inline functions using the "inline" keyword or the compiler will automatically do it for you too depending on your compiler settings.





Inlining moves the code for a function into the code that called the function. Since calling a function has some performance overhead moving the code into the calling function can result in faster performance. Realize that the code for an inlined function gets copied to every place the function is called, therefore the code size gets bigger. In general good functions to inline are short and are called frequently in tight loops.
Reply:No, they are different. A macro will always do copy + paste + substitution, for an inline function the compiler will decide if and when it will do copy + paste + substitution.
Reply:I agree with tykyle. I also add that macros are potentially dangerous. First, they can have side effects that are not always obvious. Second, you can't really debug into them, because they aren't really there. The compiler doesn't know about them, only the preprocessor. So (for c++) unless the macro is *really* simple, I'd be inclined to use inline functions.





I'd also add (with respect to use in tight loops) that the compiler always has the opportunity to optimize. True for both macros and inline.





BTW, the business about the compiler knowing about the code (vs the preprocessor only) is why #define statements are deprecated in c++ (as in #define pi 3.1415) vs const statements. Same thing.


Is there any function in c++ to center align output text ?

Try sprintf! chunk a string output buffer ... If you want to center align some text using the printf or sprintf functions, you can just use the following:





function center_text($word){


$tot_width = 30;


$symbol = "-";


$middle = round($tot_width/2);


$length_word = strlen($word);


$middle_word = round($length_word / 2);


$last_position = $middle + $middle_word;


$number_of_spaces = $middle - $middle_word;





$result = sprintf("%'{$symbol}{$last_position}s", $word);


for ($i = 0; $i %26lt; $number_of_spaces; $i++){


$result .= "$symbol";


}


return $result;


}





$string = "This is some text";


print center_text($string);





off course you can modify the function to use more arguments.

Is there any function in c++ to center align output text ?
there should not be but you can make one method.
Reply:try graphics in c++....


u can find the examples frm graphics.h header file


use "outtextxy(x,y,"output"); function


Is there a function in c to remove some lines from a text file?

* open up an infile and outfile with fopen()





* set up a loop to read each line using a function like fgets()





* make a decision about that line (keep it or kill it)





* write each 'keep it' line to the output file with fprintf()


I need homework help for calc. I need to create a function that as x approaches point c from left to right?

they are equal. Point c also must be defined, but the function cannot be continuous at point c.





I have really now idea how to do this! Does any have an example?

I need homework help for calc. I need to create a function that as x approaches point c from left to right?
What are the requirements for continuity of a function f(x) at x=c? They are:





f is defined at c,


the (two-sided) limit lim (x-%26gt;c) f(x) exists, and


lim(x-%26gt;c) f(x) = f(c)





Well, you're given that the first two hold. So...
Reply:If the function as x approaches c from both left and right approaches the same value, and f(c) is defined, then f is continuous at c, isn't it? But it might not be differentiable if there's a sharp corner at (c,f(c)). The absolute value function gives you that. f(x) = |x-2| is continuous at x = 2, and f(2) is 0, well defined, but it's not differentiable because of the corner.





Unless you mean a piecewise defined function. Something like f(x) = (x²-4)/(x-2) approaches a value of 4 at x=2, but there's a HOLE there, since f(x) is not defined for x=2. But if you separately define f(2), you can make it anything you want. If you make it 4, you've got a removable discontinuity.





On the other hand, something like f(x) = 1/x² can have f(0) = 1 added as a piecewise definition, but since f(x) gets very very large as x→0, there's not a limit, no approaching a single value, and hence no continuity.

lady palm

What is user defined function and inbuilt functions in C?

PLEASE TELL IT AS EARLY AS POSSIBLY. MAY BE TODAY ONLY

What is user defined function and inbuilt functions in C?
When you install a C compiler for a chip/operating system, there are going to be a bunch of inbuilt (or more commonly called built-in or system functions). The will be described (but not defined) in header files. Search the compiler folder and subfolders for *.h and you will see a lot of them. Open math.h (in read-only mode please) an you can scroll down and see some like sin(), cos(), tan().





User defined functions are functions that you create. For example:


----


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





void main()


{


printf("%d\n",add(3));


}





int add(int i, int j)


{


return i+j;


}


----


In this case add() is a user defined function. While printf() is a built-in function. You wrote add() but you did not write printf()





I'm assuming you will pick a "Best Answer" today as well. :)


I want to know that whether "main" function in 'c' is a predefind function or user defind function ?

main() is a function which must be defined by the programmer. So it is called user defined function. when operating system runs our program, first it calls main() function, and return control to the user. So, main() is pre-identified by the operating system and must be defined by the user.

I want to know that whether "main" function in 'c' is a predefind function or user defind function ?
main function is a userdefined functcion but its prototype is predefined. This function is recognized by C-compiler and code inside this is compiled. Also you can pass argument to main() to send it to command line compilation at DOS prompt.
Reply:Its a predefined function, that returns an integer. You can also make it take command line args.
Reply:The main function is user defined, and must be defined.





You can read more about used defined vs. predefined functions in the excellent book C++ primer plus.





Here is a link to the relavent content from the book on google:





http://books.google.com/books?id=zuyAIZ9...
Reply:main function is an user defined function only ya in c.......


Is their any predefined function in c to get multi lines from the user like in c++ cin.getline?

Good ques....i'm also waiting for it's answers..........

Is their any predefined function in c to get multi lines from the user like in c++ cin.getline?
you can tyr using this function in c.


use getch() several times where you want multi lines break.before that use this header file #include%26lt;conio.h%26gt;


The cost function is C(w,r,q)= 2Q√rw, what is the gradient and how is it solved?

I think you are supposed to solve for (w,r,q)

The cost function is C(w,r,q)= 2Q√rw, what is the gradient and how is it solved?
the gradient is an operator defined as:





grad(C) = %26lt;∂C/∂w , ∂C/∂r , ∂C/∂q%26gt;


The gradient turns a scalar into a vector, it is usually written as an upsidedown delta called the del operator or the nabla operator but I don't have that symbol. in the case of your function you would need to complete three partial derivatives:


∂C


---- = -q/(w*√[wr])


∂w





∂C


---- = -q/(r*√[wr])


∂r





∂C


---- = -1/√[wr]


∂q

snow of june

Can a function in C return a data type thta i made through struct?

OMg! Help! I need to do my homework.





If yes, ty. The error of my code must be somewhere else.


If no, OMg! I'm dead! Any other ways i could simulate this?

Can a function in C return a data type thta i made through struct?
Yes you can ... example :





struct wp_char{


char wp_cval;


short wp_font;


short wp_psize;


}ar[10];





struct wp_char infun(void)


{


struct wp_char wp_char;





wp_char.wp_cval = getchar();


wp_char.wp_font = 2;


wp_char.wp_psize = 10;





return(wp_char);


}





Hope this help
Reply:On a PC, the return value of a function is placed in the AX register - and your struct probably won't fit.





What you need to do is to return a *pointer* to the struct.





And that's bad practice.





The called function can't use an automatic variable for the struct, because when it returns that pointer, it will point to memory that's no longer allocated. If the called function mallocs space for the struct, then the calling function has to remember to free the memory when it's done with it. Too often, programmers use that same function later, forget that requirement, and end up with a memory leak.





Let the calling function create the struct as an automatic variable. Have the called function return a code indicating success or error as the return value. Believe me - I paid *dearly* to learn this lesson in writing code. Memory leaks are no fun at all.
Reply:yes





like this:





struct A


{


int a1;


char* s1;


};





struct A function(int a1, char* s1)


{


struct A retval;


retval.a1=a1;


retval.s1=s1;


return retval;


}
Reply:Yes to both questions.





You can return ANY data type from a function, but that doesn't mean you should!





When you return an object a copy of it is made and the copy is what is returned, this is slow and wasteful for large objects. And note that while your object will be copied any pointers it has may be invalid if they point to variables also declared inside the function which would have gone "out of scope".





A common and perferable alternative to returning a structure that would be bigger than say a few single int or long or doubles would be is to create a copy of your struct before calling your function and pass the function a pointer to it. eg


my_struct p;


my_func(%26amp;p);


See passing by reference vs passing by value


Write a function in C to split a list into two sub-list using pointers?

There's not enough information, what type of list, I don't think you mean an Enumerated List, and into what type of split, are you talking about linked lists, or something like indexing using trees to navigate or manage keys?

Write a function in C to split a list into two sub-list using pointers?
data structure, you are reading, good,
Reply:For i=0 to 10


who_cares=me


Next


Is static function of c++ same as static functio of java?

Yes. The only difference is that in C++ you need to call the function using Class::staticFunctionName(), while in Java you would call it as Class.staticFunctionName(). You must understand that a static function belongs to the whole class, and not individual objects.

Is static function of c++ same as static functio of java?
both are meant for same intention. means it is almost same


but slight difference in memmory allocation.like the mem allocation will be done at the load time itself in java.





i mean will be static for the whole application in java
Reply:No its different


"REPORT ON" function in c program?

this sounds like a function that must be written by the programmer. It's not a standard library function.

sweet pea

What is the iscomment() function in c/c++??????

hey this function iscomment() is used to findout whether tha given statement is a comment / not......

What is the iscomment() function in c/c++??????
checks to see if it's a comment





can someone tell me best site for searching porn? yahoo images and yahoo video are pretty good but does anyone know of sites?


A function in C that will count the number of a certain character from a string of characters from the input.?

The user must be able to enter a string of any amount of characters and the output must count only one specific character. Thank you.

A function in C that will count the number of a certain character from a string of characters from the input.?
there is a string function that will do that, I just cant remember what its called. look in the string.h file, or documentation you have for the string functions.





another way is as the other person said. its a pretty easy routine to write, just try it.
Reply:An if statement iterating through the string until it finds the null.... A simple counter variable with an if statement that adds one to the counter every time target is found...

bottle palm

A function in C that reads in a String of text and counts the number of characters including space in the text

The text max is 250

A function in C that reads in a String of text and counts the number of characters including space in the text
strlen(const char *s)
Reply:#include %26lt;string.h%26gt;


char str[250] = "Hellooo this is a test";


int len = strlen(str); //Len = 22


Write Function in C-programming to count numbers stored in a stack or buffer.?

I should be simple to understand...................

Write Function in C-programming to count numbers stored in a stack or buffer.?
In very general terms the internals of a function are roughly





Function (variable to be passed in [stack or buffer pointers] , output pointer sto variable if needed for answer)





1) Initialise the module - declare constants, initialise counters etc, reserve memory if needed, etc.





2) Loop to count each item, with a test to exit when the last item is reached.





3) release memory if needed, etc, pass back any necessary pointers to any needed variable, etc
Reply:wud u plz clearly mention wat u want
Reply:int countStackSize() {


return stack.size();


}


What function in c programming to display output as kav,vak,avk,kva,vka,akv where input is kav?

Something like this, I guess?


f(char *i){ g(i,i);}





g(char *o,char *i)


{


char c,*x;


if (!*i) {printf("%s,",o);return;}


for (x=i; *x; x++){ c=*i;*i=*x;*x=c; g(o,i+1); *x=*i;*i=c; }


}

What function in c programming to display output as kav,vak,avk,kva,vka,akv where input is kav?
AFAIK, standard C libraries do not contain permutation functions. You need to write it yourself. If you are looking for ready stuff, try to search statistics libraries at, say,


http://www.mathtools.net/
Reply:there is no such inbuilt function. you have to create it on ur own. if u want it mail me at john_r225@yahoo.com


Exit function in C++?

Is there a such thing?????





if(something == 7) {


exit


}





is there something like that???

Exit function in C++?
there is no exit statement in c++


the correct statement for what you are looking to do is break


as in





if(something==7){


break;


}





hope that helps
Reply:Actually, break doesn't exit an if statement. It only works on for, while, or switch statements.





If you're looking to exit the program, you can use the exit() function. If you're just looking to exit the if statement, there's no good way to do that. You could use a goto statement, though that's not recommended.
Reply:do you mean 'break'?
Reply:you are writing a correct C++ code but depending on your code. you might get a error with something like that.
Reply:try the following








if(something == 7) {


break;


}
Reply:There is an exit statement in c++


u need to use a header file called %26lt;stdlib.h%26gt;


and also the coding for it is as follows





if(something == 7) {


exit(something);


}





this works as i tried it out on my comp





oh and by the way the break statement is used to exit the block and by that i mean within { and }

magnolia

Fscanf function in c++ gets its input from whinh library........?

cstdio. Defines the macros traditionally defined in the Standard C library header %26lt;stdio.h%26gt;.





You can also use stdio.h as it is normally included in most of the C++ compilers.

Fscanf function in c++ gets its input from whinh library........?
I believe it is from studio.h it usually is included in all c++ compilers.


Is it legal in C++ to declare a variable in one function which has the same name as a variable declared ??

Is it legal in C++ to declare a variable in one function which has the same name as a variable declared in another function? How are the two variables related? If the value of one of these variables is changed, what effect is apparent in the other variable?

Is it legal in C++ to declare a variable in one function which has the same name as a variable declared ??
As long as they are not in the same scope it is fine. Example:





void f(int a, int b) {


int i;


int a; // Illegal - a has already been defined in this scope





for(i=0 to 100) {


int a = i; // Legal - inside the loop is a new scope


int b = ::a; // Legal - different b which is referring to the original a passed into the function


}


}





To access the same variable name in a higher scope, use the scope resolution operator '::' (See above)





void g(int a, int b) {


int i; // Legal - there is no relationship between this i and the i of function f()


}
Reply:Not illegal but can lead to some problems at runtime wherby u mite not get the desired results





consider a function calling another function. if the variable has been declared first in the outside func and also inthe inner function they there will be data probs
Reply:If you simply declare the variables in different functions, it will be legal (unless you declare them public, which changes your scope)





You can always read more on Scope, this will be clearly explained.


Explaain function for c forms? when collection to form? when?

In the case of Inter state trade or commerce, registered dealer can get goods at concessional rate of CST, if he produces a declaration in Form C to the selling dealer.





The Registered purchasing dealer can get blank form C from the Sales tax authorities of the state in which he is actually registered.





Contents of Form C---------


Form C contains particulars like name of issuing state, date of issue, name of purchasing dealer, to whom Form C is issued, his R.C.No., date from which R.C is valid, name and address of the seller with name of the state, details of the goods ordered and obtained. It bears seal of the Sales tax authority issuing the form.





Form C is issued by the purchasing dealer to the selling dealer who shall submit to the sales tax assessing authority.





A single Form C is sufficient to cover all transaction of sale which take place in one financial year between the same two dealers.


If f '(c) = 0, then x = c is a critical point for this function?

If f '(c) = 0, then x = c is a critical point for this function (true or false)

If f '(c) = 0, then x = c is a critical point for this function?
This is true, please see your textbook. These T/F questions you post are basic ideas in calculus that would probably be in bold boxes in your book. If f'(c)=0 or if it does not exist, then c is indeed a critical point.
Reply:Actually the point would be (x, f(x)). x = c is not a point - it could be called a critical value I think though.
Reply:That is TRUE. That is, in fact, the definition of critical point (a point where the first derivative vanishes).

forsythia

Function in c++ to reverse an array of float elements?

http://cppreference.com/cppalgorithm/rev...





Store all the floats in a vector, and then use reverse().





vector%26lt;float%26gt; numbers;


numbers.push_back(3.1f);


numbers.push_back(1.f);


numbers.push_back(7.3916f);


reverse(numbers.begin(), numbers.end());

Function in c++ to reverse an array of float elements?
usin temp variable u can reverse the numbers.





float arr[10];//array of elements


int temp;


for(int i=0;i%26lt;max;i++) //max-%26gt;highest no. of elements.


{for(int j=max-1;j%26gt;=0;j--)


{temp=arr[i];


arr[i]=arr[j];


arr[j]=temp;


}


}





thats it the array is swapped..





Hope this helps u
Reply:You probably need to create a second array and then get the last elements from the first array and put then in the front of the second array.





Something like this...


# Elements in a





Create 2nd array same size





then something using a while like...


b[firstelement]=a[lastelement]


then


b[1]=a[lastelement-1]





etc.





Just create your own.


C programming: Returning multiple arguments from a function.?

In C, how do you return multiple arguments from a function? I'm pretty sure it needs pointers... But I have no clue how!





Please go easy on the jargon, I'm just learning!

C programming: Returning multiple arguments from a function.?
Yeah you got it right. You have to use the pointers for that purpose.


If you have to return the values that are of the same data type (eg. int) then you can use array to return multiple values.


But if you need to return values of different data types, then you have to use the pointers (in C).


for example: this function will put values in a, b and c and return them all.


void ReturnVals(int %26amp;a, int %26amp;b, int %26amp;c)


{


a=2;


b=3;


c=4;


}





call this function from somewhere else using the code like:





int val1,val2,val3;


ReturnVals(val1, val2, val3);


printf("%d, %d, %d",val1,val2,val3);





Then you'll get the output as 2,3,4


As you've seen we've succeeded in getting multiple return values from the function ReturnVals.
Reply:You can't return more than one argument from a function call. However, there are ways around this. The easiest way is to create a structure and then pass the address of the structure as one of the arguments to the function call. The function can then assign values to the various members of the structure and they will still be intact when the function exits. I hope this isn't too heavy on jargon. Here's an example: (but please forgive any syntax errors - it's been years since I did C programming...)





main()


{


struct


{


int a;


char b ;


} myStruct ;





DoFunc (%26amp;myStruct) ;


printf ("a=%n, b=%c\n", myStruct.a, myStruct.b) ;


}





void DoFunc (myStruct *TheStruct)


{


TheStruct.a = 2;


TheStruct.b = 'q' ;


}





A should be equal to 2 and b should be equal to q.
Reply:when defining the function, put multiple arguments in the brackets.





main(a, b, c)





instead of





main(void)





Hang on, that might be arguments supplied _TO_ the function, err, sorry, I'm learning too.





Good luck.
Reply:The only way to return multiple arguments is to return a struct. It is not obligatory to use pointers. You have to define a struct with all the information you need to return


typedef struct sth { int a;


int b;


char c;}sth;





sth func(int aa,int bb,char cc)


{ sth my_sth;





my_sth.a=aa;


my_sth.b=bb;


my_sth.c=cc;





return my_sth;


}





main()


{ sth sth_ret;


int a1=1,b1=2;


char c1='a';





sth_ret=func(a1,b1,c1);





printf("%d %d %c\n",sth_ret.a,sth_ret.b,sth_ret.c);


}
Reply:Here's the "complete" way to do it.





#include%26lt;iostream%26gt;





using std::cin;


using std::cout;


using std::endl;








void Return2variables(int %26amp;variable1, int %26amp;variable2);





int main()


{


int variable1;


int variable2;





cout %26lt;%26lt; "Enter a variable: ";


cin %26gt;%26gt; variable1;





cout %26lt;%26lt; "Enter another variable: ";


cin %26gt;%26gt; variable2;





Return2variables(variable1, variable2);





cout %26lt;%26lt; endl %26lt;%26lt; endl;


cout %26lt;%26lt; "You have exited the function and now you're in main function" %26lt;%26lt; endl;


cout %26lt;%26lt; "Here are the variables after they got converted: ";


cout %26lt;%26lt; variable1 %26lt;%26lt; "," %26lt;%26lt; variable2 %26lt;%26lt; endl;





system("PAUSE");


return 0;


}





void Return2variables(int %26amp;variable1, int %26amp;variable2)


{


cout %26lt;%26lt; "You're in the function" %26lt;%26lt; endl;


cout %26lt;%26lt; "These are the variables before they get converted: ";


cout %26lt;%26lt; variable1 %26lt;%26lt; "," %26lt;%26lt; variable2 %26lt;%26lt; "," %26lt;%26lt; endl;





variable1 = 17;


variable2 = 18;





}
Reply:I don't really use C, but you could probably do this by returning an array or some type of object.
Reply:All the answerers here are terrible. Some of you give misguided answers. The code many of you write is flawed. If you don't know C, don't write a wrong answer. Please stop. It's one thing to be a poor programmer yourself, don't make others bad.





http://c-faq.com/misc/multretval.html





A structure is probably easiest. If you're using pointers, have pointers passed in through the function arguments, and then modify the values pointed to by the pointers.





Be careful of returning pointers. If you declare a variable on the stack, pointers to it won't be valid after the function returns. So if you're returning pointers, make sure they point to memory on the heap.


C++ Leap Year Program with error C2659: '=' : function as left operand problem?

Okay here is my program, it has only two compiles errors: C2659: '=' : function as left operand. I'm new to C++ and get confused by this error, can anyone correct my program? Thanks. Here is the program:





#include %26lt;iostream%26gt;


#include %26lt;cstdlib%26gt;





using namespace std;





int getYear();


bool isLeap(int year);


char moreData();





int main()


{


int year;


char carryOn='y';





while(carryOn=='y'||carryOn=='Y'){


year=getYear();





if(isLeap(year)){


cout%26lt;%26lt;" is a leap year\n";


}else{


cout%26lt;%26lt;" is not a leap year\n";


}


carryOn=moreData();


}


system("pause");


}


int getYear(){


int year;


cout%26lt;%26lt;"Enter a year: ";


cin%26gt;%26gt;year;


return year;


}


bool isLeap(int year){


if(year%4==0){


if (year%100!=0){


isLeap=true;


}else if (year%400==0){


isLeap=true;


}


//return isLeap;


}}


char moreData(){


char carryOn;


cout%26lt;%26lt;"Do you want to enter more data? (y/n) ";


return carryOn;


}

C++ Leap Year Program with error C2659: '=' : function as left operand problem?
in your isLeap() function.. you are assigning isLeap=true.... which cannot be done.. because isLeap is the pointer to the function isLeap().. dont worry if you dont understand that..... But you can use the statement


return (true);


instead of


isLeap=true;


and use the statement


return(false);


at the end of the isLeap function just before the closing flower brace.. that will make the program work...
Reply:I think your





isLeap=true;





statements need to be





return true;





instead!


Find y as a function of x if e y - C = x + 3?

Find y as a function of x if e y - C = x + 3

Find y as a function of x if e y - C = x + 3?
(x+3+c)/e=y
Reply:Do you mean e^y?





if so,





e^y - C = x + 3


e^y = x + 3 + c


y = ln(x + 3 + C)

jasmine

What is the function of the strtok command ? ( in c programming)?

What is the function of the strtok command?


a. finds the number of characters that occur from the beginning of the string.


b. adds the second string the first string.


c. separates the first string by the characters in the second string


d. finds the pointer to the first occurrence of a specific character in the string


e. none of the above

What is the function of the strtok command ? ( in c programming)?
It splits a line into "tokens" that have "delimiters" between the "tokens". The "delimiters" are usually white space and punctuation.
Reply:Hi there





I won't give the answer, but here's the explanation:





The strtok() function returns a pointer to the next "token" in str1, where str2 contains the delimiters that determine the token. strtok() returns NULL if no token is found.





See this url for more information and you can choose your answer.





http://www.cppreference.com/stdstring/st...





Hope this helps


C(x)=.005x^2+ln1.2x, cost function, find # of items for min marginal cost & evaluate C(x) &marginal cost for x

c(x)=.005x^2+ln1.2x, cost function, find # of items for min marginal cost %26amp; evaluate C(x) %26amp; marginal cost for x thanks

C(x)=.005x^2+ln1.2x, cost function, find # of items for min marginal cost %26amp; evaluate C(x) %26amp;marginal cost for x
c(x) looks like a cost function to me, so take


d c(x)/dx to get the marginal cost function, set it equal to zero and solve for x to find minimal marginal cost items. Is there something in the function you have trouble taking the derivitive of?


Returning an array from a function and/or calling the array from another function in the same header file, C++

My problem is that I want to call an array from one function in a header file and then input it into another function in the header file. For example consider the code.





Class MyExample{





private:


double Array1[16], a, b;


int n;





public:





double function1(int n);


double function 2();


};





MyExample::function1(n){





for(a=0;a%26lt;n,a++){


Array1[n] = a;


}


}





MyExample::function 2(){


//I need to get Array1[n] into this function!


for(a=0;a%26lt;n,a++){


Array1[n] = Array1[n]/b;


}


/*


Whats more is that I want to be able to have Array1[n] not be converted to a int because n is an integer.





Also then how would I return Array1[n] to the .c++ file?





Thanks, any help is appreciated as it is getting a bit irritating since I just can't pass the thing.





Brian


*/

Returning an array from a function and/or calling the array from another function in the same header file, C++
Maybe I am not understanding what you are asking, but it looks easy to just pass the array. And pass the value of n - don't use a global.





double Array1[n]


function1(Array1, n);


function2(Array1, n);





void MyExample::function1(double *array, const int size)


{


for (int a = 0; a %26lt; size; a++)


array[a] = a;


}


void MyExample::function 2(double *array, const int size)


{


for (int a = 0; a %26lt; size; a++)


array[a] = array[a]/b;


}





Since you are passing a pointer, you are passing by reference - yes?





And these functions would be typed as void, unless you are returning something not evident in your code.
Reply:You're welcome. Report It

Reply:Define the array globally.
Reply:I'm not sure why you can't just pass the array. You should be able to do:





double * function1(int n);





double function2(double * arrayEntry);





all you will need to do is define the length of the double array globally instead of manually setting it to 16 everywhere, that way the functions become extensible and easier to change.


Thursday, July 30, 2009

Given the function f(x)= ax^2+bx+c?

a)write down the other x intercept if the vertex is (-3,-4) and one x-intercept is (-5,0).


b) another function h(x) has the same roots as f(x) but has y intercept (0,-20). Find the values of a,b,and c for h(x). Rewrite the equation into turning point form by completing the square.








any help with any of the sections is greatly appreciated!

Given the function f(x)= ax^2+bx+c?
(a)


The axis of the function is vertical. Each x-intercept is therefore at the same horizontal distance from the vertex.





The horizontal distance from (-5,0) to (-3, -4) is 2, and moving 2 units to the right of -3 gives -1. The other x-intercept is:


(-1, 0).





(b)


An equation with roots -1 and - 5 is:


g(x) = (x + 5)(x + 1)


g(x) = x^2 + 6x + 5





At the y-intercept, x = 0, and y = 5.


To make the y intercept 20 requires multiplication by 4, giving:


h(x) = 4g(x)


= 4x^2 + 24x + 20.


= 4(x^2 + 6x) + 20


= 4(x^2 + 6x + 9) + (20 - 36)


= 4(x + 3)^2 - 16.

crab apple

F(x) = x ^3 + 3 x ^2+ 4 x +b sin (x) + c cos(x) is one one function for all x belogs to R (real set).?

f(x) = x ^3 + 3 x ^2+ 4 x +b sin (x) + c cos(x) is one one function for all x belogs to R (real set). Then find the greatest value of





b^ 2 + c^ 2 ?

F(x) = x ^3 + 3 x ^2+ 4 x +b sin (x) + c cos(x) is one one function for all x belogs to R (real set).?
b² + c² is unbounded so it has neither local nor global extrema..








Doug
Reply:there is no greates value for f(x)


since the lim x-%26gt;infinity f(x) is infinity





now, b and c can be arbitrary, as large as you want or as small as you need.


so again, there is no gretes value of b^ 2 + c^ 2
Reply:Some progress...





Can rewrite as





f(x) = x³ + 3x² + 4x + √(b² + c²) sin ( x + atan(c/b) )





Is one-one if f '(x) ≥ 0 for all x





f '(x) = 3 (x+1)² + 1 + b cos x - c sin x.





Numerical experiments show that b = 13.31 and c = 20.74 is close to the maximum values of b and c, giving a maximum value of b² + c² of about 607.3 .





Continuing...





The condition on b and c: 3 (x+1)² + 1 + b cos x - c sin x ≥ 0 for all x defines a region in the b-c plane bounded by straight lines. The envelope of this family of lines is found from the above equation, and its derivative.





Changing b, c and x to x, y and t makes these equations more standard, where t is a parameter.





The family of lines is:





cos(t) x - sin(t) y + 3 (t +1)² + 1 = 0





The envelope curls around the origin and cuts itself at about (13, 21). This point of intersection is furtherest from the origin, corresponding to maximizing b² + c²





The derivative wrt t is:





-sin(t) x - cos(t) y + 6 (t+1) = 0





The point of self intersection corresponds to two parameters, s and t. The equations are





cos(t) x - sin(t) y + 3 (t +1)² + 1 = 0


-sin(t) x - cos(t) y + 6 (t+1) = 0





Solving for x and y:





x = 6 (t+1) sin t - [3 (t +1)² + 1] cos t





y = [3 (t +1)² + 1] sin t + 6 (t+1) cos t





Similarly for s, therefore:





6 (t+1) sin t - [3 (t +1)² + 1] cos t = 6 (s+1) sin s - [3 (s +1)² + 1] cos s





and





[3 (t +1)² + 1] sin t + 6 (t+1) cos t = [3 (s +1)² + 1] sin s + 6 (s+1) cos s





These 2 simultaneous equations in s and t can be solved using Newton's Method to get





s = -3.490373 and t = 1.490373





(Note that s + t = -2 !!! but why??)





Substituting, and using the original b and c instead of x and y, find that





b = 13.3188707 and c = 20.7429121 with b² + c² having a maximum value of





607.6607208.


F(x) = x ^3 + 3 x ^2+ 4 x +b sin (x) + c cos(x) is one one function for all x belogs to R (real set).?

f(x) = x ^3 + 3 x ^2+ 4 x +b sin (x) + c cos(x) is one one function for all x belogs to R (real set). Then find the greatest value of





b^ 2 + c^ 2 ?

F(x) = x ^3 + 3 x ^2+ 4 x +b sin (x) + c cos(x) is one one function for all x belogs to R (real set).?
6


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

all the back of the book 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 function f(x)= 2/(4x^2 + 9)?
f(x) = (2/9) /( 1+(2x/3)^2)


= (2/9)( 1 - (2x/3)^2 + (2x/3)^4 - (2x/3)^6 ...)


alternating series


converges if (2x/3)^2 %26lt; 1


i.e. |x|%26lt;3/2


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


Function for copying a file in c language?

for writing nc i should copy file from a drive and paste it in other


drive or location .what function i should use for copying a file.


and also for cuting a file.


notice:i am programing in c.

Function for copying a file in c language?
On UNIX style systems you can execute commands with the system call, for example





system("cp pathname1 pathname2")





Likewise on Windows but with copy instead of cp.





http://www.die.net/doc/linux/man/man3/sy...








Windows has a CopyFile function which can be called from C.





http://msdn.microsoft.com/library/defaul...
Reply:This is not tested and has no real error checking but should get you started.





int copy (char * src, char * dest)


{


char buf[1024];


FILE * in, *out;





in = fopen(src, "r");


if(in == NULL)


{


return(-1);


}





out = fopen(dest,"w");


if(out == NULL)


{


return(-1);


}





while(fread( buf,


sizeof(buf),


1,


in))


{


fwrite(buf,


sizeof(buf),


1,


out);


}


fclose(in);


fclose(out);


return(0);


}
Reply:Or you can have the program do it with the appropriate calls. Use C file I/O to open the file, write it to another file at the new location, close both. Then make calls to appropriate functions to delete the old files if needed. I beleive that unlink works in *nix and kill works under DOS or DOS box. You'll have to look up the Windows functions if you need it in the Win32 or Win32s APIs. I hope this helps.
Reply:DanD is quite rignt. One additional detail: you can use function "system" in DOS and Windows also.


system( "copy pathname_1 pathname_2" );


If you want to "cut" the file call then


system( "del pathname_1" ) for Windows


of


system( "rm pathname_1" ) for *NIX

strawberry

A quadratice function, P(x)=Ax^2+Bx+C is called a quadratic approximation of the function f?

for values near a, provided that the following 3 conditions are satisfied.


f(a)=p(a)


f'(a)=p"(a)


f"(a)=p"(a)


A.) For values of x near a=0, find a quadratic polynomial, p(x)=Ax^2+Bx+C, that is a quadratic approximation of the function f(x)=e^-x^2


B.) Use the function p to approximate the value of f at x=1/2 and x=2

A quadratice function, P(x)=Ax^2+Bx+C is called a quadratic approximation of the function f?
For any function f and point a, you can compute the Taylor series of f around a:





T(f,a,x) = f(a) + (1/1!)f'(a)x + (1/2!)f''(a)x^2 + (1/3!)f'''(a)x^3 + ...





If f is well behaved, this sum gives the value of f(a+x)





So, taking only the first three terms, you have a quadratic Q(x) that approximates f(a+x) and has the properties:





Q(0) = f(a)


Q'(0) = f'(a)


Q''(0) = f''(a)





Now let P(x) = Q(x-a), then P is a quadratic and has all the needed properties.


How do i add values to an array in C++ using a function.?

I have a set of values that i read into an array using a function earlier on, now i need to add additional values to the end of the array. hot do i go about doing that.

How do i add values to an array in C++ using a function.?
probably u had used a loop for earlier reading ,


then here's how it goes . i'll show an example.


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


void main()


{int a[20],i,n,m;


cout%26lt;%26lt;"\n How many elements ?";


cin%26gt;%26gt;n;


for(i=0;i%26lt;n;i++)


{


cin%26gt;%26gt;a[i];


}


cout%26lt;%26lt;"\n How many elements do you want to add ?";


cin%26gt;%26gt;m;


for(;i%26lt;n+m;i++)


cin%26gt;%26gt;a[i];


}





the idea here is , u hav executed for loop for the first reading , so u dont change the value of i that ws updated when it ws in the loop. Further reading takes place frm wer it ws stopped. Bt ur array size should be such that it can accomodate m+n elements
Reply:These are some way you can do


1. new array with maximize size array[MAX] and int _array_len variable.


Ex: len = 2;


buffer = new[len];


//TODO: init value


when u want to add value then just increase len++


buffer[len++] = value;


2. You should use collection like List or ArrayList





I hope it can help