Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Prime numbers in Cartesian axis

Hello everyone :)
I have written a program using C Language that prints all prime numbers using a loop.

I would like to print these numbers in a Cartesian axis. I have tried to include the library graphics.h, but I can't do it because it says me "File not found".
Is there another way to do it?

My code:
C:
#include <stdio.h>

int main () {
    int n, d;

    for(n=1;;n++) {
        for(d=2;d<=n/2;d++) {
            if(n%d==0) {
                break;
            }
        }
        if(n%d!=0) {
            printf("* %d\n" ,n);
        }
    }
}

Thanks a lot :)
 
A quick Google suggests to me that the library is not a standard library which is probably why you're getting the file not found error.

Given its age, people have previously suggested that you should try a library like SDL or GTK instead. There is a port of the original library called "WinBGIm" but that's also old so I don't know what kind of mileage you'll get out of it.

I can't pretend to know much about this so I'd say have a Google and take a look at StackOverflow for some more guidance - where it appears a very similar question was asked before.

Hope you manage to find a solution :thumbsup:
 
I have also did a quick search and have unfortunately returned with nothing...

When I did my quick search, I essentially just found the same results as @swift. <graphics.h> is not a Standard C Header. You can use a Library called 'WinBGIm' and that you should probably use a Library such as SDL or GTK(But I'd suggest making a couple basic Programs using those Libraries before making a SDL/GTK Program that involves a Cartesian-Axis).

i did try looking up online for how to do a Cartesian-Axis in C, but only got C Tutorials and results for what a Cartesian-Axis is(Note: Unlike @swift, I use Qwant instead of Google, so I will have gotten different results. Depending on you Search-Engine, you will also get different results. But, I suggest looking at what results you get and see if it relates to any of this).

Anyways, by the looks of it, you might be on your own for this one. I'm sorry that I couldn't help with this. Again, look deep into the search-results and see what you can find. If you decide to do it in SDL or GTK(+) then study them first before making an actual Program with them.

Good luck!
 
Back
Top Bottom