Sunday, August 2, 2009

I'm having trouble in running the user defined function in C programming?

I can printf for 0 to 9 but not %26gt; 9


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


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


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





int main(void)


{ int input, sum=0, product=1;


void spdigit(int, int*, int*);





printf("If number = ");


scanf("%d", %26amp;input);





spdigit(input, %26amp;sum, %26amp;product);


printf("SDIGIT = %d\n", sum);


printf("PDIGIT = %d\n", product);





return 0;


}





void spdigit(int input3f, int *sumf, int *productf)


{ int noofdigits, counter=0, i;





do


{counter++;


noofdigits = input3f/10;


} while ( noofdigits != 0 );





int remainder1[counter], remainder2[counter];





remainder1[0] = input3f%10;


remainder2[0] = remainder1[0];





for ( i=1; i%26lt;counter; i++ )


{ remainder1[i] = input3f%(10*i);


remainder2[i] = remainder1[i]; }





*sumf+=remainder1[0];


*productf*=remainder1[0];





for ( i=1; i%26lt;counter; i++ )


{ remainder2[i]-= remainder1[i-1];


remainder2[i]/= 10*i;


*sumf+=remainder2[i];


*productf*=remainder2[i]; }


}

I'm having trouble in running the user defined function in C programming?
The corrected %26amp; tested (for several times) code is--------------------------------------...

















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


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


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





void spdigit(int input3f, int *sumf, int *productf)


{


int noofdigits,b=1,counter=0, i=input3f;


int *rem1;


do


{


counter++;


noofdigits = i/10;


i=i/10;


}


while ( noofdigits != 0 );


i=0;


rem1=(int *)malloc(sizeof(int)*counter);


*(rem1+0) = input3f%10;


b=input3f;


for (i=1; i%26lt;counter; i++ )


{


b=b/10;


*(rem1+i)=b%10;


printf("\n%d",*(rem1+1));


}


*sumf+=*(rem1+0);


*productf*=*(rem1+0);


for ( i=1; i%26lt;counter; i++ )


{


*sumf+=*(rem1+i);


*productf*=*(rem1+i);


}


}

















Corrections are:-%26gt;


1. you can use malloc for dynamic memory allocation.


2. It is not necessary to use remainder2


instead I have used variable b whose value is inpower of 10 %26amp; which divides the total value each time by 10 so that eliminiting last digit. All Digits are stored in array pointed by rem1.











Thank you.





Mandar Gurav


Walchand College of Engineering,


Sangli,


Maharashtra,


India.
Reply:All of your printf function calls look good, so my guess is that the problem is in the spdigit function. Use a debugger to make sure that spdigit is doing what you want/expect/need it to do.





You could try this to test your printf for multi-digit output if you really want to:





int x = 1234;


printf("%d\n", x);
Reply:Your do while loop is faulty

garland flower

How do I return a 2D array from a function in C?

do i need to use pointers/struct in order to make it easier? If possible, a straightforward and simple way would do... thanks!

How do I return a 2D array from a function in C?
You cannot pass an array to a function by value. A pointer is always passed. You can get the same result as pass-by-value by declaring the array as const. Then the called function cannot change any values in the array.





A contrived by hopefully instructive example.





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








void cannotChange1(const int arr[], const int size)


{


int i;





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


{


printf("%d\t", arr[i]);


}





printf("\n");


}








void cannotChange2(const int *arr, const int size)


{


int i;





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


{


printf("%d\t", arr[i]);


}





printf("\n");


}








void canChange1(int arr[], const int size)


{


int i;





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


{


arr[i] = arr[i] * 2;


printf("%d\t", arr[i]);


}





printf("\n");


}





void canChange2(int *arr, const int size)


{


int i;





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


{


arr[i] = arr[i] * 2;


printf("%d\t", arr[i]);


}





printf("\n");


}








int* viaReturn(int *arr, const int size)


{


int i;





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


{


arr[i] = arr[i] * 2;


printf("%d\t", arr[i]);


}





printf("\n");








return(arr);


}








int main(int, char **)


{


int a[3] = {1, 2, 3};


int *b;





cannotChange1(a, sizeof(a) / sizeof(int));


cannotChange2(a, sizeof(a) / sizeof(int));





canChange1(a, sizeof(a) / sizeof(int));


canChange2(a, sizeof(a) / sizeof(int));





b = viaReturn(a, sizeof(a) / sizeof(int));





int i;





for (i = 0; i %26lt; sizeof(a) / sizeof(int); ++i)


{


printf("%d\t", b[i]);


}





printf("\n");


}
Reply:You can always create the 2D array off the heap and then pass the address back to the caller and then have the caller use it for whatever but not to forget to free the space when you are done...





Another alternative is to pass in the 2D array as a parameter into the function (by reference) and then filll it and then just leave the function which would maintain the array's content.





You mentioned you are using "C" and not C++ so unfortunately you dont have the luxury of alias nor the new/delete keywords....





I hope i didn't confuse you....because i am not sure you level of what i am talking about maybe i should explain s'more?





It's been a while since i've looked at C but for your 2D array you can pass it back by allocating memory off the systems heap space by using malloc(..) ... my appologies if C uses a different function for this....it's been a while....C++ is more elegant....so in this example:





int *my2DArray;


malloc(my2DArray,sizeof(int)*10);





This will create a 2D Array that can hold 10 integer values.





so here is what your function would look like:





int* MyFunction(void)


{


int *my2DArray = NULL;


malloc(my2DArray,sizeof(int)*10);





/* Do stuff Here */





return my2DArray;


}








void main()


{


int *myArray=NULL;


myArray = MyFunction();





/* Do whatever here */





free(myArray);





}


What is the difference between a method an d function in c++?

the major difference between method and function is





Function have the return value.





In Method there is no return Value.

What is the difference between a method an d function in c++?
A procedure is a sequence of zero of more statements combined under one common name.





A function is a procedure that returns a value.





A method is a procedure or function that is part of a class; sometimes it's also referred to as member function. Which term is used depends largely on the programming language that the speaker is used to.





Note that lots of people, even the ones who are aware of the above distinctions, use the terms procedure and function interchangeably.


How do you pick up a baby and normally function after C-section?

I am 27 weeks and hope I don't need one, but from those with experience - did it hinder getting close to, picking up, nursing baby, etc?

How do you pick up a baby and normally function after C-section?
It is a little more uncomfortable, but it is still possible to do all the things your new baby will need. Hopefully you have someone to help you for the first few days or so.
Reply:i had two c sections on i'm 28 weeks about to have another section. What helped me the most was my husband, i would not have been able to do it without him, When i need to nurse my husband would bring the baby to me, but after about a week i was able to do most of it on my own.
Reply:Having a c-section does not keep you from holding or nursing your baby. You will be sore from the c-section and need help caring for it due to the fact that you can't be as mobile or do lots of movement because you are healing from major surgery. I have had 2 c-sections and 1 vaginal birth. The difference between the births for me was that I needed more healing time and rest with the c-sections. But, you can still nurse and hold your baby...but, may need help picking your baby up for a few days.
Reply:Nope doesnt hinder a thing...just recovery process is slower, you move around slower, you will need a pillow for nursing, etc..but you still pick up the baby the same way anyone else would.
Reply:some people say you move around slower, but I have to disagree. Ihad to 2 naturally and my last one was c-section. I thought that the c-section was much easier than the vaginal deliveries, because with my 2 other children I had to have an episiotomy and I think you move around much slower and the clean up is a bigger pain in the butt
Reply:no you can still hold the baby and feed it and change it and stuff it just takes a little longer to get up and down and its hard to stand for a long period of time so you learn to do things quick and you learn how to do things like a change him/her while you are sitting. But after about a week or two it startes to get better. I have had 2 c-sections and i did everything by myself for both. tyr not to take the pain meds unless someone is around to help you if you get dizzy or sleepy and if you are alone ask your doc for a lower dose prescription or for something that wont make you tired. Oh yeah wether you take meds or not you are gonna be really tired its nice to have someone there so you can nap but if not you will live. that goes away after about 2 weeks too. Good luck and Congrats


C++ reading from file into array using a function?

text file contains title of store then a product code, product name, then product price. so type string, string, long respectively. program compiles and runs fine until count is returned in main. something is wrong with the loop and i don't know what. this is the important stuff:


--------------------------- function: ----------------------------


long readFile (string code[], string product[], long price[])


{


const long ITEMS = 24;


string temp,


store;


long count;


ifstream fin ("program5.txt");





getline(fin,store);


count=0;


fin%26gt;%26gt;temp;





while (!fin.eof())


{


temp=code[count];


getline(fin,product[count]);


fin%26gt;%26gt;price[count];





count++;


fin%26gt;%26gt;temp;


}


fin.close();


return count;


}


----------------from main:-----------------


.......


count=readFile(code,product,price);


fout%26lt;%26lt;count%26lt;%26lt;endl;





for (pos=0; pos%26lt;count; pos++)


{


fout%26lt;%26lt;code[pos]%26lt;%26lt;endl;


fout%26lt;%26lt;product[pos]%26lt;%26lt;endl;


fout%26lt;%26lt;price[pos]%26lt;%26lt;endl;


}


....





if more info is needed i can provide it. reminder this is c++

C++ reading from file into array using a function?
count looks ok--not sure why count is giving you a problem.





Look at the line just following the while declaration. You have the left side and right side inverted. Use:





code[count] = temp;

blazing star

How can we pass a multidimensional array to a function in C?

You pass a pointer to it.


void doStuff(char **pJunk) {


...


}





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


char junk[3][4];





... fill it in





doStuff(junk);





}

How can we pass a multidimensional array to a function in C?
Toadaly's solution doesn't tell how the function would know the array's dimensions...
Reply:#define COLUMN 3





void Dump(int buffer[][COLUMN])


{


for(int row=0; row %26lt; 5; row++)


for(col = 0; col %26lt; COLUMN; col++)


printf ("row: %d\tcol: %d\t%d\n", x, y, buffer[row][col]);


}





int main()


{


int g[5][COLUMN];





/* fill g up */





Dump(g);





return(1);


}


Suppose that the cost function for a product is given by C(x) =.002^3 -9x + 4000.?

Suppose that the cost function for a product is given by C(x) =.002^3 -9x + 4000.


Find the production level that will produce the minimum average cost per unit.





If you could show your work so I can get a better understanding of this problem it would help me.

Suppose that the cost function for a product is given by C(x) =.002^3 -9x + 4000.?
average cost: A(x) = C(x)/x.





minimum: A'(x) = [xC'(x) - C(x)] / x^2 = 0





then xC'(x) - C(x) = 0


C'(x) = C(x)/x


it occurs when the marginal cost equals the average cost.


solve for x .... x is the desired production level.


There is a problem with your function... it is not expressed properly... §





It is better to solve the equation: xC'(x) = C(x)


x *(.006x^2 - 9) = .002x^3 -9x + 4000





anyway... i believe its at x = 100.


Does anyone know how to make a stopwatch function in C++ (emacs) that runs on a Unix OS?

I tried using sys/time.h but it says the file is not found and I usually don't program on Unix at all but it is required for a class and I have no idea what to do.





I also need to make the timer start when the user presses a key.

Does anyone know how to make a stopwatch function in C++ (emacs) that runs on a Unix OS?
At the link is a simple timer example.


How do you take the sin of a function in c++?

I am trying to perform sin(pi*0.5), but I cant get it to work. Here is my code:


#include%26lt;iostream%26gt;


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


using namespace std;


const double PI = 4.0*atan(1.0)


int main()


{


x = sin( pi*0.5 );


cout %26lt;%26lt; x;


}


It will not give the correct answer. Any help?

How do you take the sin of a function in c++?
error 1 -- x should be declared like





double x;





error 2 -- there is a ; at the end of const double ...





error 3 -- the const is PI all caps.





It works on my machine.

imperial

Consider a three-state model for Helix-coil transition h, c, and i write expression for partition function?

Consider a three-state model for Helix-coil transition h:helix,coil:c, and intermediate:i. Assume the model is non-cooperative. write expression for partition function of such a chain.

Consider a three-state model for Helix-coil transition h, c, and i write expression for partition function?
h= (C*I/A+T/k)*z*log(.7*y)
Reply:h= (C*I/A+T/k)(.7*y)


How do you return a pointer from a function in c++?

Just assign the desired variable to the pointer that was used in the function.

How do you return a pointer from a function in c++?
int* func1()


{


int* a;


return a;


}


List all possible ways to program the NOT function in C++.?

If you mean binary negation "~", then you can use:


~x = x ^ 0xFFFFFFFF (or however many bits your complier uses)


~x = -x - 1


or you could use a really big lookup table with every possible value in it (not very efficient)

List all possible ways to program the NOT function in C++.?
simple macro:


#define NOT(expresion) (!expresion)





or simple function:


int NOT(int expresion)


{


return !expresion;


}





example:


int b;


b = NOT(5 %26lt; 0);


/* value of b = true */


b = NOT(true);


/* value of b = false */
Reply:Well NOT is taking the Opposite. so if you created a function with 1 parameter (the variable that is being "NOT"ed) use the - (negative) sign. it work work.





NOT true = false





That's all you are doing.





Hope that helps.


If a competitive firm has a total cost function of C=450+15q+2q^2 q=25 and price=115 how do i find the profit?

Profit = total price - total cost


so start by working out Total Cost





Total Cost = 450 + 15q + 2q^2, where q=25


= 450 + 15*25 + 2*(25^2)


= 450 + 15* 25 + 2*625


= 450 + 375 + 1250


= 2075





Total price = unit price * quantity


= 115 * 25


= 2875





Therefore,





Profit = 2875 - 2075 = 800

If a competitive firm has a total cost function of C=450+15q+2q^2 q=25 and price=115 how do i find the profit?
calculte the cost by puting 25 in for q, then profit =(price-cost)q

elephant ear

What is the correct form of the main function in C if i expect command line arguments?

Is it like this?


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


And if the first argument represents the filename (and location), then argc counts all arguments, or just those except the first one. In other words, a program with no extra arguments would have argc==1?

What is the correct form of the main function in C if i expect command line arguments?
You have two synthaxes :


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


and


2) int main(int argc, char **argv);





When a program starts, the arguments to main will have been initialized to meet the following conditions:





- argc is greater than zero.


- argv[argc] is a null pointer.


- argv[0] through to argv[argc-1] are pointers to strings whose meaning will be determined by the program.


- argv[0] will be a string containing the program's name or a null string if that is not available. Remaining elements of argv represent the arguments supplied to the program. In cases where there is only support for single-case characters, the contents of these strings will be supplied to the program in lower-case.





To illustrate these points, here is a simple program which writes the arguments supplied to main on the program's standard output.





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


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





int main(int argc, char **argv)


{


while(argc--)


printf("%s\n", *argv++);


exit(EXIT_SUCCESS);


}
Reply:yes, a program with no extra argu have argc==1.


Give me some details of non-recursive function in 'c' programming language to reverse a doubly linked list.

node.next -%26gt; node.next.next = my head will explode


How am i using this exp() math function wrong? C++ programming?

float newBalance = principal * ( 1 + interestRate )exp( years );





im trying to make it (1 + interestRate ) to the power of years.





Any insight would help.





Thanks

How am i using this exp() math function wrong? C++ programming?
There are a couple things wrong with your statement. First, you need to look up exp() and see what it does. It doesn't do what you think it does. Second, exp() is a function, not an operator, so you can't just stick it between two parenthesized expressions.





What you want is pow(). pow(1 + interestRate, years) will do what you want.
Reply:Syntax for exp() function is given below:





double exp ( double x );


float exp ( float x );


long double exp ( long double x );





I believe what you are trying to do is new balance = principal x (1 + interestRate) x exp(years)





for this use





float newBalance = principal * ( 1 + interestRate )*exp( years );





As (1 + interestRate)exp(years) is syntactically wrong... because its missing * operator between ( 1 + interestRate ) and exp() function which the compiler can't interpret... So leads to syntax error


Only One program using all the string function in C Program?

Which function are you keenly looking for? If you have to use any string function in C language, you need to include the String.h header file as #include%26lt;string.h%26gt;. string.h has all the list of string functions such as strlen(), strcpy() etc. Use help function in the C editor to know the list of string functions and their usage.

lady palm

Can u explain the importance of volatile function in c program?

Nope.

Can u explain the importance of volatile function in c program?
The volatile keyword for a Storage Class modifier informs the compiler that the variable can be modified in ways unknown the the compiler. Although this is a new feature, it is not available with old compilers, the concept is not. This usually applies to the variables mapped to a particular memory address viz.,device registers.





In their cases it is important for the series of statements to be executed exactly as they are written and not reordered for optimization purposes. The best example would be the keyboard where you read the character from the keyboard and store it to a corresponding variable.


Ex:


void get_keyboard()


{


extern char KEYBOARD;


char c0,c1;





c0=KEYBOARD;


c1=KEYBOARD;


}





Here you store 2 values to c0 and c1 using the same variable KEYBOARD,which means the variable KEYBOARD holds different values to be stored at c0 and c1 seperately. However the compiler unaware of this fact will store the KEYBOARD value in a register and then store it to c0 and c1 resulting the same value to be assigned to both c0 and c1. So in order to get it goin to ensure the KEYBOARD is read twice you declare it volatile.





extern volatile char KEYBOARD;





This should answer your question i guess!


Can u explain the importance of volatile function in c program?

http://gcc.gnu.org/onlinedocs/gcc-3.0.4/...


How to find address of an overloaded function in C++?

the address in memory? yuck!





You could play address math in c, but it is distasteful in higher level languages.


Give me an example of user define function in C language please?

A user defined funtion is one that has a proper signature i.e. name, return type (optional in some cases) and arguments e.g.





//function declaration, can optionally be written outside


//the 'main' function


bool myFunction(int x, int y);





//the funtion returns true if y is divisible by x,


//otherwise it returns false


bool myFunction(int x, int y)


{


if(x%y == 0)


return true;


else


return false;


}

snow of june

Function calling array C++?

Hi, I'm stuck on a problem I'm doing, I was wondering if someone could help. I need to create 3 functions


1. Max temp


2. Min temp


3. Average temp





An array will be populated with the appropriate no of temps . The functions will perform the calculations and display the results to the user





How would I approach this? I'm only started to learn about arrays and am clueless really. How would I find the max and min in a function?





I would really appreciate any help you culd provide

Function calling array C++?
int fn_GetMax(int* pInput, int length)


{


int ret = -1 ;


if(pInput != 0 %26amp;%26amp; length %26gt;= 1)


{


ret = pInput[0];





for(int i=1; i%26lt;length; i++)


if(pInput[i]%26gt; ret) ret = pInput[i] ;





}





return ret;


}





int fn_GetMin(int* pInput, int length)


{


int ret = -1 ;


if(pInput != 0 %26amp;%26amp; length %26gt;= 1)


{


ret = pInput[0];





for(int i=1; i%26lt;length; i++)


if(pInput[i]%26lt; ret) ret = pInput[i] ;





}





return ret;


}





int fn_GetAvr(int* pInput, int length)


{


if(pInput == 0 || length %26lt;= 0)


return 0;


int sum = 0 ;


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


sum+= pInput[i];





return sum/length;


}





______________________________________...





good luck
Reply:Well, with out giving it completely away in code:





Draw it out on a sheet of paper, use an array with 5 elements as an example. Make up some temps {32,-4,78,55,77}.





Now, imagine you can't see the array, except for the first element. How would you go through the entire array and determine the maximum temp (the highest number) or the minimum temp (lowest number)?





Basically, you want to compare each number until you find the largest or smallest. Just start with the first element: for maximum: if the first number (current) is smaller than the next, then next becomes the current and compare it to the next number. If the next number is smaller than current, then keep the current number as current. For smaller, reverse the logic.





Average, well, you know what that is, add it all up and divide by the number of elements.
Reply:For the minimum and maximum, "guess" a minimum and maximum as some element of the array. Then, loop through the array, and if you find anything greater than your current guess for the maximum or anything smaller than your current guess for the minimum, then update your guess appropriately. When you are done, the guess for the minimum/maximum will be the actual minimum and maximum values. For the mean, simply sum all the elements and then divide by the number of elements, the same as you would by hand.


What does 'f' represent in "printf" function in C language?

why they used printf instead of print?

What does 'f' represent in "printf" function in C language?
The class of printf functions stands for "print formatted" :)
Reply:print formated.....
Reply:As he said there is a family of functions used for formatted output! printf, fprintf, sprintf, etc!





Don't ask me why they made so many! Ask Dennis Ritchie! printf prints to the standard output so it is the most common one!





I even like printf...print is just too common! printf is original...it is elite :p
Reply:Hi!! f in printf stands for format or formated





At first it may appear that C's basic IO functions look strange compared


to "cin" and "cout". But in fact "scanf" and "printf" are very powerful


tools. The "f" in "printf" and "scanf" stands for "formated". The first


argument to printf is always a string which defines a format. Here's an


example:





int x = 3; int y = 4;


printf("x is %d and y is %d",x,y);


What is the use of malloc() function in C?

malloc is used to allocate memory from the heap. for example if you want an array of fifty integers:





int * array50 =(int *) malloc(50 * sizeof(int));





then you can use it as an array as long as you need it. for example:


array50[3] = 4; //assigns element 3 just like a static array.





the idea is that if your program only allocates memory while you need it you are free to use lots more memory instead of tying it up loads of memory with static declarations.








when you are done you use free


free(arrray50);

What is the use of malloc() function in C?
Since memory in a computer is a shared resource, when you need to use memory to store some data the program has to ask for memory, so the operating system can assign to your program certain segment of tha RAM memory.


Example:


malloc (30)


will assign to your process 30 bytes of memory. The operating system knows where in the memory is that segment, you only get a pointer to that address.





To ask for space for 50 integers:





int * a = (int *) malloc (sizeof(int) * 50);





and so on...


Bye.
Reply:malloc() allocates a block of memory on the heap and returns a pointer to the block.





When you use malloc(), you must later use free() to de-allocate the memory when it's no longer needed.





See http://en.wikipedia.org/wiki/Malloc


I need to create a random function in c++ using this formula =f(x) × 100 , f(x) = (pi + x)^5?

i need the help fast plz

I need to create a random function in c++ using this formula =f(x) × 100 , f(x) = (pi + x)^5?
I can give you video tutorial on how to use the rand() function:





http://xoax.net/comp/cpp/console/Lesson2...





I hope that helps. Could you give some clarification?
Reply:I shall give you some quick and dirty code which implements the formulae you have given me. It is random in the sense that anything I do is random and unfocused when it's quick and dirty. Its output is not random because it always seems to return 1. Obviously, you'll have to debug it yourself (but this sounds like homework so you should anyhow) and this may help anyhow.





#include %26lt;iostream%26gt;


#include %26lt;cmath%26gt;





using namespace std;





float funky(float );





int main()


{





double x, Rand;


int i;





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


cin %26gt;%26gt; i;





x=(double) i;





Rand=funky(x)*100.0;





cout %26lt;%26lt; rand;


return 0;


}





float funky(float x)


{


double pi=3.14159;


double temp1, temp;


temp=(pi*x);


temp1=pow(temp,5);


return temp1;


}

sweet pea

How do i calculate the cost function for c(x) = 7000 + 2x ?

I think this is the cost function. If you want the marginal cost, it's c'(x) = 2

How do i calculate the cost function for c(x) = 7000 + 2x ?
That is the cost function.


Can we use main before include function in c++ ?

This is not a very well worded question, but I think you are asking "Can main come before #includes". If so, yes, includes can come along anywhere in C++.

Can we use main before include function in c++ ?
#include %26lt; %26gt;


Void , int , .... main()


{


....





return 0 ;


}


Void , int ,.... function1 (..... , .... , ...)


{





....


}


This code is correct ....


If you meant to ask for that answer ....

bottle palm

In a competitive market with a total cost function of C(q)=4q^2 + 16 and the marginal cost function MC(q)=8q?

need variable cost, fixed cost, AC, AVC,AFC

In a competitive market with a total cost function of C(q)=4q^2 + 16 and the marginal cost function MC(q)=8q?
4Q, man, 4Q


What is a formal name for function declaration ? (C++)?

thank you

What is a formal name for function declaration ? (C++)?
c represent the letter C.


because there was languages before "C" named "A" %26amp; "B" then our "C".


And "++" coz there is an operator in the "C" called "++" not found in other languages.


Function declaration:





returnValue functionName(parameters);
Reply:Not sure, but, The Declaration?


How can I write a function in C++ and win32 that draws a cube?

this is my assignment and need to do it asap!

How can I write a function in C++ and win32 that draws a cube?
i am not sure of the function, i would go to


http://www.planet-source-code.com/ and take a look at sample codes, i have used this side for code.


Can u help with "srand" function in c...please?

ok my program is to produce any integer between 60 to 180.lets say X. then again i need to produce any integer wich should be between square root of X and square root of X+20. my program is like this:





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


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


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


#define low_d 60


#define high_d 120


#define G 9.8


int


main(void)





{





double i, seed ;


double A, low_v, high_v,randomd ;





srand(time(0));








randomd = low_d + rand() % (high_d + 1 - low_d);


printf("\n%f\n ", randomd) ;








A = randomd * G;


printf("%f",A);





low_v = sqrt(A);


high_v = sqrt(A)+20;








srand(time(0));


printf("speed = %f",rand() % high_v + low_v);

















return(0) ;


}














so the prob is that it produces only integers as a random numbers. but i need real numbers. so when i use double and %f or %.2f it shows error " invalid operands to binary %"





any ideas??

Can u help with "srand" function in c...please?
I just did a complete search on my computer for "s rand srand" s r a n d, hidden or not, and found nothing relating to your computer problem. Sorry, I can not help you with your problem. Be aware that changing Windows functions or other settings, hidden or not, can be detremental to your computer, possibly only fixable by a computer programer that charges a lot of money.

magnolia

How can CONVERSION STRING to FUNCTION in C?for example "f(x)=sin(x=3)+x?

you can't just do it.





compare the string to "sin" and then call the sin function





if(myString == "sin")


{


sin(x);


}





you're going to have to do the processing there though. I'd say consume characters to the first open-parenthesis, and then compare it, then consume what's inside the parenthesis.

How can CONVERSION STRING to FUNCTION in C?for example "f(x)=sin(x=3)+x?
The link below will get you close although it is in C#. Can't remember if C has an Eval function but the gyst is to take any string and break it down into its parts character by character. You will have to extract the variables (x in your case) and you will need to ask the caller what is the value for x. Not sure this is what you are looking for.





The other thought is to offer a function f that takes a value (x) and returns sin(x) and if no value is passed, the I guess you default x to be 3.
Reply:From the little information you gave, I can guess that you want the user to input some function as a string, and then make that as a function within the program dynamically. Well it is possible, but it is a very lengthy process, and certainly not something I would be doing now.


Need help making a power function in C using loops. This is what i got so far.?

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


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





void float DP(double x, int n)


{


double x, DP;


int n;





DP=pow(x,n);


printf("%d to the %i power is %d", x, n, DP);








}








int main()


{


float x, DP;


int n;





scanf("%d%i", x, n);


DP(x, n);





printf("Answer equals %d\n", DP);





return 0;


}

Need help making a power function in C using loops. This is what i got so far.?
double DP(double x, int n)


{


double result = x;





for(int i = 1; i %26lt; n; i++)


{


result *= x;


}





return(result);


}
Reply:Oops, misread what you said in my first response -- you said you need to use loops. Very well:





double DP(double x, int n) {





double result = 1.0;


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


result *= x;


}





printf("%f to the %d power = %f\n", x,n,result);





return result;


}


Lcm gcd program with recursive function in c language?

Hi I'm not exactly remembering the algorithm. I think its like this.





int gcd(int a, int b)


{


int g;


if(b==0)


g=a; //if b=0 then gcd will be a


else


{


if(b%26gt;a)


swap(a,b);


else


a=a%b;


g=gcd(b,a);


}


return g;


}





For example a=40 and b=16





Level 1:


a=8 b=16 // after a = a%b. Now we are calling gcd(16,8)





Level 2:


a=0 b=8 // after a = a%b. Now calling gcd(8,0)





Level 3:


Now b==0 and hence gcd will be 8.





Now you can find the lcm from the formula gcd*lcm = a*b





Yeah for lcm, lcm = (a*b)/gcd





Is it enough!


How do I save a function in C++?

I already made the code,now all I have to do is save it.


How to do it?

How do I save a function in C++?
just save the code file or compile it to a lib file. I don't understand your problem
Reply:just press, ctrl + S. nothing else!
Reply:You can save a function in separet Header File.... Then include this file in your code to call this function again and again.

forsythia

What is the most important function in C++?

thanx for help

What is the most important function in C++?
the "main" function. without it you wouldnt have a program!!
Reply:Kind of a silly question, I guess the pointer operator (*). Without it, C++ would be a lot different and a lot less performance friendly.
Reply:Each an every function is important. U cant say which is important. Its not an exam, to tel that this and that are important. Functions are used to use it whereever it is required.


I can say in development(IT industry), uses String functions and date function. Any one who is well versed in these two in any language can shine well. I mean to say his/her job will be easy
Reply:Your best functions/methods are the ones you declare yourself. They are the ones that end up doing the things that required you to write a program in the first place.





-BoneSaw


We dont use & in scanf function in c for reading strings .y is it so?

Bcoz, the char itself returns the address...


so no need for using '%26amp;' before it...

We dont use %26amp; in scanf function in c for reading strings .y is it so?
yeah! we don't use scanf ,instead we use 'gets' %26amp; for printing a string we use 'puts'. this is b'coz scanf won't take spaces in between words,but using gets would avoid this problem.
Reply:Yes buddy,





take the below eg.





int number;


char name[10];





when ever you specify the name of a integer variable, i.e number, you are indicating just the content of the variable. If you get a input for that variable, you have to store that input in the memory location. so when put %26amp; before the variable name, ie. %26amp;number, now you are indicating the memory location of that integer, where you are going to store the input.





But in the case of string, whenever you specify the name of the variable, you are directly indicating the base address of that string. i,e by giving just name with out %26amp;, you specify the start address of the memory location from where you have store the input.





. . .


How can i call javascript function in c# web based?

You can't directly call into a Javascript function, but you may:


1) create a client side script from the server side (a page that outputs %26lt;script%26gt;alert('some message')%26lt;/script%26gt; for instance)


2) there's some new support in Asp.NET 2.0 for client to server interaction (AJAX)


3) you may look for ATLAS which is a foundation just for that kind of things (Web 2.0 in general)


Is there a text formatting function in C++?

Something like


format("Integer %i \n String %s",integer,string);


???

Is there a text formatting function in C++?
No, not in standard C++. As you indicated, printf() is still available to C++ as a library function. However, you stated that you're not interested in printf().





cout/ofstream and manipulators are considered far superior to the C standard library in most respects. Internally, the C++ implementation of stream I/O is much more efficient and the syntax can be considered more natural to code in many situations. For instance, cout statements don't need to be parsed at runtime unlike a printf() format string.





Also, printf() is not object-oriented so it is still around for backward compatibility but is not the preferred C++ output mechanism. With C++ stream I/O, you can actually extend %26lt;%26lt; with operator overloading to support custom output of your own classes/structures.

jasmine

Can you write a "split" function in C?

I blew an interview because I screwed up my pointer arithmetic while parsing a string:





Here is the syntax:





prompt%26gt;./split "This Is an input string" " "





output:


This


is


an


input


string





or:


prompt%26gt;./split "This is an input string" "p"


output:


this is an in


ut string





I tried putting '\0' wherever the split character occurred, but I couldn't turn it into an array of substrings.





Any ideas?

Can you write a "split" function in C?
Only strlen, strcpy, and strcat, eh? That's pretty harsh. I think you have the right idea putting '\0' at the split points. Instead of creating an array of substrings, though, create an array of pointers to the substrings.





Pseudocode:





char *s points to your input string


S is an array of pointers to char


char *p declared to walk through the input string


initialize p = s, i = 0





do {


set S[i++] = p


set p to next split point


set *p = '\0'


p = p + 1


} until last substring found





How about that? You don't even need any of those string.h functions!
Reply:And you weren't allowed to use strtok?


Write c program to delete one character from string without using string handling built in function of c?

e.g.


my string is "hello"


and i want to delete 'l'


so my abnswer will be : "heo"

Write c program to delete one character from string without using string handling built in function of c?
Here it is. Rewrite as you wish:





void Remove(char *p, char ch)


{





char *temp;


temp=p;


while (*temp!=NULL)


{


if (*temp==ch){


while (*temp!=NULL){


*temp=*(temp+1);


if (*temp!=NULL) temp++;


} /*end while*/


temp=p;


} /* end if*/


temp++;


}/*end while*/


} /*end Remove*/





EDIT: C passes everything by value (that is it creates a new variable it copies the contents of parameters into) EXCEPT arrays. It creates pointers to arrays. Thus, in this program the calling function I used is:





int main()


{


/* Declarations*/


char Array[50], ch;





printf("Enter a string:");


gets(Array);








printf("Enter a character to remove:");


ch=getc(stdin);


printf("Your string is:\n%s\n", Array);


Remove(Array, ch);


printf("Your string is:\n%s\n", Array);


return 0;


}








You can send it the name of the array or you can send it %26amp;array[0] or whatever you like.


What is a use flag() function in c language?

It is actually used to give a specific address of a variable to be called..


If f,g are analytic function on C s.t fg=0,show either f or g is 0?

Hint: If an analytic function is 0 on a set with its accumulation point, then the function is identically 0.





Now, either f or g has to have this property since at each point one or the other is 0.

crab apple

Write a C/C++ program which consists of a user-define function Prime. This function will take a number and che

Write a C/C++ program which consists of a user-define function Prime. This function will take a number and check that the number is prime or not if the number is prime Display The number is Prime other wise display The number is not PrimeCall this function in main program.

Write a C/C++ program which consists of a user-define function Prime. This function will take a number and che
#include %26lt;iostream%26gt;








// The following function works on positive numbers only


bool Prime(int number);





int main( )


{


int number = 0;


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


cin %26gt;%26gt; number;





if(Prime(number))


cout %26lt;%26lt; "The number is prime" %26lt;%26lt; endl;


else


cout %26lt;%26lt; "The number is NOT prime" %26lt;%26lt; endl;





return 0;


}





bool Prime(int number)


{


for(int i = 2; i %26lt; number - 1; i++)


{


if((number % i) == 0)


return false;


}


return true;


}
Reply:Don't post the question from your assignment to Internet; try to use your own imagination and skills you learnt from lectures; rather these assignments are brain teasers to make you ready for exams.
Reply:First thing you need to do is set a cin%26gt;%26gt; statement for the user to enter a number. Then have the an if-then statement that checks the number against the formula for determining if a number is prime (I dont remember if off the top of my head but its something like a number thats only divisable by itself). Then you can set your cout%26lt;%26lt; after the if as "The number",x,"is prime." and then for the else cout%26lt;%26lt; "The number",x,"is not prime." Should work out fine. No need to make it more complicated than it needs to be.
Reply:The code given by Silver is pretty good. I am only suggesting minor improvements to the same code








#include %26lt;iostream%26gt;








// The following function works on positive numbers only





// Haidry Comments:


// long is larger in size and hence can accommodate larger


// numbers. The prototype could be


// bool Prime(long number).


// Haidry Comments End





bool Prime(int number);


int main( )


{


int number = 0;


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


cin %26gt;%26gt; number;





// Haidry Comments:


// Use of 'abs' function can eliminate the


// problem with negative numbers. The call could be like this


// if (Prime(abs(number))


// Haidry Comments End





if(Prime(number))


cout %26lt;%26lt; "The number is prime" %26lt;%26lt; endl;


else


cout %26lt;%26lt; "The number is NOT prime" %26lt;%26lt; endl;





return 0;


}





// Haidry Comments:


// If you changed the prototype above make necessary


// change here as well


// bool Prime(long number)


// Haidry Comments End





bool Prime(int number)


{





// Haidry Comments:


// The loop does not need to run till 'number -1'. It only


// needs to check integers up to half of the 'number'. So the


// for loop could be as following


//for(int i = 2; i %26lt; number / 2; i++)


// Haidry Comments End





for(int i = 2; i %26lt; number - 1; i++)


{


if((number % i) == 0)


return false;


}


return true;


}


How to add a function in C library ?

Try and get in touch with the C standards committees. Easiest way is to post on comp.lang.c (or is it comp.std.c?). Anyway, explain your superbly amazing function, writing the implementation code, and why it should be including the standard library.





Then debate over it, trying to survive the probes of a number of other brilliant minds. Try to keep everyone convinced that your function is the next best thing, for about a decade or whenever the next standard gets released. Then, there you go ;p





Oh wait, did you intend something else? Sorry, I'm not psychic, so you may have to say something more. More = more than one vague line.

How to add a function in C library ?
Do you mean how to properly program headers?


How to use arc function in c any example??

Hold 'Alt' and Press The Tab, Swithes Between Screens...





Or you can set programes to open with Ctrl + Alt + *LETTER*


(right click an icon to set it)





Hope this helps you get the most out of your Keyboard! ^.^


If the total cost function is c(x)=1/2x^2-5x+500, find the production level that will minimize aveerage cost?

take the derivative of the function, and you get:


c'(x)=x-5





Solve the above to find where c'(x)=0, and you get x=5.





So, the solution is x=5. This is the value of x that gives the minimum cost for c(x).





Hope this helps.

strawberry

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.























}








}