After compiling main.c on the command line in command prompt everything is fine. Then I type in main.c and the program opens up in Notepad.
Edit: Probably because I'm putting in the .c at the...
Type: Posts; User: Adrian
After compiling main.c on the command line in command prompt everything is fine. Then I type in main.c and the program opens up in Notepad.
Edit: Probably because I'm putting in the .c at the...
I chose notepad to be the program to open it up with and now whenever I run the program from the command line (it compiles without problems now) my program code will just open up in notepad. How...
Ahh, that would make sense, I moved it to a folder in my documents, now I get that Windows cannot open the file main.c (but I have permission at least) and it wants to know what program I want to use...
I am running Windows Vista Home Premium and have not been able to get MinGW working with command prompt yet. I think I am pretty close though. Currently when I make a simple C program to run and...
Trace the following program to determine its output.
#include <iostream>
using namespace std;
void foo (int *a, int *b)
{
*a = *a + *b;
*b = *b + 2;
Alright, a 2d array would make sense, thanks a lot.
Alright, that's what I was expecting to do. How would I get each line of text into an area where I can use the bubblesort process on them? I know each character is being read, but I'm not sure how...
I am supposed to take the contents of 1 text document and output it into another by have the lines alphabetized.
Your program should:
– open the file input.txt
– read all the lines in input.txt...
This is what it should be:
int isPrime ( int number )
{
int x = 1;
int i = 2;
int isPrime ( int number )
{
int x;
int i = 2;
for(i=2; i<number ; i++)
{
if((number%i) == 0)
I am supposed to write a function that determines if a number is prime or not. I return 1 if it is prime and 0 if it is not.
This is what I have so far:
int isPrime ( int number )
{
int...
Somehow I have to ignore the '-' and do the same process but multiply it by -1 at the end. I think I can do this.
Edit: I got it, thanks again for your help.
Actually, it gives me 0 for negative numbers because I'm returning 0 (since value = 0 before the for loop, which won't run if they have a '-' at the beginning of the string). How would I get the...
Brilliant, thanks a lot, this works very well.
Sorry, but I don't know what either of those would do or where to implement them.
How would I go about changing a string of numbers like "2546" and return the integer value 2546.
This is what I have so far (this is just my function to convert the string to an integer)
The 48...
If you're suggesting that it's not necessary to have these in the code, then I get your point, but I'm just going with what the compiler says. I get 0 on the assignment if it doesn't compile...
It says there's a parse error if I don't put the semi-colon there, which I know is strange, but it shuts the compiler up. I took it out and still had the same problems, so that's not what's...
#include <iostream>
using namespace std;
int getItemPrice()
{
int price;
// making sure cost is not negative
do
{
I just tried getItemPrice in another program and it did work, I tried every order of negative, non-multiples of 5, and other numbers that I could and it worked every time.
As for the other things,...
If I had the program:
#include <iostream>
using namespace std;
void getItemPrice()
{
I'm not sure how to keep track of something like that though, however, that is the same idea I had.
Wait, I could go n/k= first
And then output would be cout << k << " ^ " << "first"
I'll...
I have a program that will find prime factors of any input number
#include <iostream>
using namespace std;
int main()
{