What do you mean? I just compiled the program and it printed all the primes from 2 to 150 without any problems.
Type: Posts; User: vxs8122
What do you mean? I just compiled the program and it printed all the primes from 2 to 150 without any problems.
Thanks. All I did is change P array size to 151 and that fixed the problem. What this code does is finding all prime numbers from 2 to 150 using Sieve of Erastosthenes algorithm.
See code below:
#include <stdlib.h>
#include <stdio.h>
int main ( int argc, char *argv[] )
{
int P[150] = {}, i, j;
Ok, I now see why it exits like that. And yeah, it's not worth a trouble fixing this over a homework problem. Thanks much!
Ok now, I modified again and it worked pretty well. However, if I typed something like "10a" I get something like:
Enter a temperature in Fahrenheit (enter a nonnumeric value to exit):
10a...
I followed what you suggested, but right now the program loops once no matter what value I input. I need to make it loop again when the input is a numeric value.
Here is the modified program:
...
See my code below:
/*
* ======================================================================
*
* Filename: ex08.c
*
I expected this program to print out:
Enter your desired monthly salary: $2000___
Gee! $2000.00 a month is $24000.00 a year.
Instead, it printed out:
Enter your desired monthly...
Oh wow, I feel retarded. I just realized that f is actually a number not a notation for floating number.
As for hexadecimal system in C programming, why does .1 really equal to 1/16 plus 5/256, not just 1/16?
For instance, the number 0xa.1p10 should theoretically equal to:
(10*160 + 1*16-1)*210 =...
I checked inside the main.c file and on line 29, I noticed that the variable was already used:
bool isActive = true;
Yet the compiler does not recoginze that. Why did that happen?
Is there a way to ignore this specific warning?
I was following this GDB debugging tutorial:
Peter's gdb Tutorial: Debugging With Your Brain
I downloaded, extracted and tried to compile the file spinning_cube.tar.bz2 using make command. I...
From what I understand about pointers:
int k = 5; // create a new variable k with a value of 5
int *ptr; // create new pointer ptr
ptr = &k; // make ptr point to the address of k
*ptr...
No I did not create setjmp.h, it is already included in the library. Check out setjmp.h - Wikipedia, the free encyclopedia.
Other question: does longjmp() cause a frame in the middle of the stack to be deallocated?
For example:
#include <stdio.h>
#include <setjmp.h>
I see! The numbers are being treated as boolean TRUE and FALSE. Thanks for clearing up.
Then that leads to other question. I don't understand the sythax of this part. It sounds like an uncompleted sentence "If not setjmp(buf), then run function first()."
See example below:
#include <stdio.h>
#include <setjmp.h>
static jmp_buf buf;
Thanks, I understand now. So there is absolutely no way to resize the double_digit array while keeping all the data?
You are correct, however, the old values are stored in new_array (see lines 28-33) then later stored in the new double_digit array.
What I am trying to do is to have the program create 2D array that for each row, no two numbers are the same and only consists numbers between 1-9. The array lists out every possible combinations. ...