Monday, May 24, 2010

Can someone help me with writing this C program?

I need to make a program that does the following :





1) Prompt for and then accept 10 floating point values from the


user.


2) Store these values in an array.


%26lt;I completed steps 1 and 2 %26gt;


3) Pass the array to a procedure which prints out the values to


4 decimal places in a numbered fashion (i.e like line numbers).


4) Pass the array to a function which returns the maximum value.


5) The returned maximum value is printed out in scientific or


exponential format along with a suitable heading.





I haven't leanred anything on procedures or functions , so I'm stuck on step 3. Can someone please show me how to do this ?

Can someone help me with writing this C program?
hey has your teacher given you any assignment ???
Reply:I would really suggest you post questions like this on a C forum . You will most likely get a better answer there.





http://www.codeguru.com/forum/forumdispl...
Reply:Or else you may contact a C expert at websites like http://askexpert.info/ to help you code your project assignment.


C# change array of strings into one string.?

Hi, in the software I'm developing (nothing professional, just as a hobby, I'm only 16), I have an array of strings, and sometimes the array can be as large as 1 million. Each string in the array holds 10 characters. At the moment the program has to work through the array like this:


string total = null;


int x = 0;


while (x %26lt; myArray.Length)


{


total = total + myArray[x];


x++;


}





This takes upto half an hour with my processor (it's a 3.0GHz dual core, but I realise only one core is being used).





Is there a quicker way to do what I'm doing? If so, how?





Thanks, Thomas





BTW if you want to try the software, it can be found here:





www.wormalds.co.uk/ThomasWormaldEncryp...

C# change array of strings into one string.?
Well, I don't know of any shortcut method to what you're doing. Maybe this setup might run faster, but then again, maybe not.





string[] what = {"So", " what", " if", " I", " have", " this?"};





string newAns = null;





foreach(string ans in what)


newAns += ans;





If this doesn't work out to be any better, then its time to use threads. You mentioned that only one core is being used. You could break up the task and do some of the work in different threads. However, you'd have synchronize the efforts and merge everything back into once string at the end, so you'll have to wait for each thread to complete its task.
Reply:Why the hell would you have an an array of one million strings? What possible practical use does that have?


How can i make one c++ program read the virtual memory of another?

This is my problem...i need to use 2 matrixes, for fast information channels...in my algorithm. I can declare one of them in a program. If i declare both, then the program crashed (apparently due to some windows xp mem limit per program. When i declare 1 matrix in one program, but another in another program, and try to run both...i just get an error message saying that my page file is too small...so if i run this on a better computer, i'd be able to declare both matricies at once from two places. Now, i need to make the first program communicate with the second.


I want the first program to declare a matrix/array...get the memory address for the first element of the array, and length, and send that info through a text file to the other program...that would then take that number...load it into a pointer, and view the matrix without declaration. But this isn't working, why not?

How can i make one c++ program read the virtual memory of another?
There are a few ways that shared data can happen.





- create a RAM drive that has fast access. Then use both programs to open the same file. This is a GET IT DONE method.





- my second suggestion is what you have tried. But here is what might be wrong. Both programs have to be compiled, using the same compiler options. As I recall, if you use a LARGE scale object option, the pointers might work out universally. (the type of computer is not relavant).





- The other option is to install an ODBC text file or other global data structure. This could be an awesome and transportable method that would work on countless Windows computers of different flavors and environments. (Yet, I could not even begin to describe the programming details).





Good luck
Reply:I don't think you can just access shared memory on a whim, each modern program loads onto a computer in a separate memory space, the only way to communicate is through API calls, and memory addresses shouldn't be passed in them.





The other way is piping one program output into a master program but that is not going to solve your problem; in other words, without declaration is unlikely.


How can i make one c++ program read the virtual memory of another?

This is my problem...i need to use 2 matrixes, for fast information channels...in my algorithm. I can declare one of them in a program. If i declare both, then the program crashed (apparently due to some windows xp mem limit per program. When i declare 1 matrix in one program, but another in another program, and try to run both...i just get an error message saying that my page file is too small...so if i run this on a better computer, i'd be able to declare both matricies at once from two places. Now, i need to make the first program communicate with the second.


I want the first program to declare a matrix/array...get the memory address for the first element of the array, and length, and send that info through a text file to the other program...that would then take that number...load it into a pointer, and view the matrix without declaration. But this isn't working, why not?

How can i make one c++ program read the virtual memory of another?
There are a few ways that shared data can happen.





- create a RAM drive that has fast access. Then use both programs to open the same file. This is a GET IT DONE method.





- my second suggestion is what you have tried. But here is what might be wrong. Both programs have to be compiled, using the same compiler options. As I recall, if you use a LARGE scale object option, the pointers might work out universally. (the type of computer is not relavant).





- The other option is to install an ODBC text file or other global data structure. This could be an awesome and transportable method that would work on countless Windows computers of different flavors and environments. (Yet, I could not even begin to describe the programming details).





Good luck
Reply:I don't think you can just access shared memory on a whim, each modern program loads onto a computer in a separate memory space, the only way to communicate is through API calls, and memory addresses shouldn't be passed in them.





The other way is piping one program output into a master program but that is not going to solve your problem; in other words, without declaration is unlikely.

anther

How to make an array using pointers in C++?

#include "stdafx.h"


#include %26lt;iostream%26gt;


using namespace std;





void print (int* a, int* b, int arraySize) {


int* aPtr;


int* bPtr;


int i;





cout %26lt;%26lt; "The values:" %26lt;%26lt; endl;


for (i = 0, aPtr = a, bPtr = b; i %26lt; arraySize;


cout %26lt;%26lt; "A[" %26lt;%26lt; i %26lt;%26lt; "]: " %26lt;%26lt; *(aPtr++) %26lt;%26lt; endl,


cout %26lt;%26lt; "B[" %26lt;%26lt; i %26lt;%26lt; "]: " %26lt;%26lt; *(bPtr++) %26lt;%26lt; endl, i++);


}





int main() {


const int arraySize = 10;


int* a = new int[arraySize];


int* b = new int[arraySize];


int* aPtr;


int* bPtr;


int i;





// initialise


for (i = 0, aPtr = a, bPtr = b; i %26lt; arraySize; *(aPtr++) = 1, *(bPtr++) = 2, i++);





// print


print(a, b, arraySize);





// copy


for (i = 0, aPtr = a, bPtr = b; i %26lt; arraySize; *(aPtr++) = *(bPtr++), i++);





// print


print(a, b, arraySize);


}

How to make an array using pointers in C++?
void main()


{


int i;





int *ar[10];





int num[10];





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


{





ar[i]=%26amp;(num[i]);


}





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


{


cout%26lt;%26lt; *(ar[i]);


}


getch();


}
Reply:try this link





http://www.intap.net/~drw/cpp/
Reply:array a[15]


a[0]=9;


a[0]-%26gt;next=a[1]=4;


......


you have to define next before you use it as global variable


These are all true/false questions for C programming?

1. The preprocessor directive #define RING 1 tells the C preprocessor to replace each occurrence of the constant RING with 1.





2. The fourth element of an array named bob is bob[4]





3. All arrays with 10 elements require the same amount of memory.





4. A function with return type void always returns the value 0.





5. A function prototype tells the compiler nothing about the value that is returned by the function.





6. When an array is passed to a function, the address of the array is passed to the function and a copy of the elements is made for the function to manipulate.

These are all true/false questions for C programming?
Good luck doing your own homework!





(And neither of the two answerers below is 100% right, btw.)


 


 


 


 
Reply:1). true


2). false


3). true


4). false


5). true


6). false.


Ok now you won't learn anything from these true/false answers...
Reply:Why can't you do your own homework?
Reply:1 t


2 f


3 t


4 t


5 f


6 t


C#??structured array??

can you give me a sample of a structured array,, and how to access its elements?? im not sure if im doing it right but when i compile i get errors


public struct stud


{


public string fname;


public string lname;


}





my question is....where should i place the array??? need help please........

C#??structured array??
A struct doesn't stand for structured array, they're two different things. If you want to use a struct, just put it anywhere in the class alongside your methods.





@Jordan Z





An array is ALWAYS limited in memory, which is why it has such fast lookups. You must define a type and size before you allocate an array, no matter what the language. Some languages just do better than others at hiding this from you (ex. ArrayList copies the array to a new one somewhere else, then deletes the original).