473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

flowchart

1-develop a flowchart and then write a c program to display all prime
number less than the number entered by the user.
Jun 27 '08 #1
19 4099
sameer wrote:
1-develop a flowchart and then write a c program to display all prime
number less than the number entered by the user.
homework alert!

Try it yourself first and show what you tried and were you got stuck

Bye, Jojo
Jun 27 '08 #2
sameer wrote:
1-develop a flowchart and then write a c program to display all prime
number less than the number entered by the user.
What benefit do you expect to gain from a flowchart?

Displaying all prime numbers less than some N is trivial. It's /not/
displaying /composite/ numbers that's hard ...

--
"It would have to be enough." /Brokedown Palace/

Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England

Jun 27 '08 #3
sameer wrote:
1-develop a flowchart and then write a c program to display all prime
number less than the number entered by the user.
What exactly do you expect from this post? Have you made an attempt
yourself? If so, post your code, however incomplete or ugly it may be.
I suppose you do know what prime numbers are? How would you solve the
second part of your problem with a pen and paper? Your maths textbook
should have algorithms for doing this. Try implementing them in C.

Jun 27 '08 #4
sameer wrote:
1-develop a flowchart and then write a c program to display all prime
number less than the number entered by the user.
Flowcharts are difficult in monospaced text, so I'll leave
that part to you. Here's the program, though, with error- and
sanity-checking omitted for brevity:

#include <stdio.h>
int main(void) {
unsigned int limit;
unsigned int value;
printf ("Number, please? ");
fflush (0);
scanf ("%u", &limit);
printf ("The prime numbers less than %u "
"are listed below:\n", limit);
for (value = 2; value < limit; ++value)
printf ("\t%u\n", value);
printf ("... along with a few false positives.\n");
return 0;
}

--
Eric Sosman
es*****@ieee-dot-org.invalid
Jun 27 '08 #5
Eric Sosman wrote:
sameer wrote:
>1-develop a flowchart and then write a c program to display all prime
number less than the number entered by the user.

Flowcharts are difficult in monospaced text, so I'll leave
that part to you. Here's the program, though, with error- and
sanity-checking omitted for brevity:

#include <stdio.h>
int main(void) {
unsigned int limit;
unsigned int value;
printf ("Number, please? ");
fflush (0);
Can you tell me why you're using 0 instead of stdout?
scanf ("%u", &limit);
printf ("The prime numbers less than %u "
"are listed below:\n", limit);
for (value = 2; value < limit; ++value)
printf ("\t%u\n", value);
printf ("... along with a few false positives.\n");
return 0;
}
Jun 27 '08 #6
In article <g2**********@registered.motzarella.org>,
santosh <sa*********@gmail.comwrote:
>Eric Sosman wrote:
>printf ("Number, please? ");
fflush (0);
>Can you tell me why you're using 0 instead of stdout?
$ man fflush
When calling fflush, if stream is a null pointer, all files open for
writing only and all files open for update whose last operation was a
write are flushed.

--
"There is nothing so bad but it can masquerade as moral."
-- Walter Lippmann
Jun 27 '08 #7
On Wed, 11 Jun 2008 16:08:51 +0000, Walter Roberson wrote:
In article <g2**********@registered.motzarella.org>, santosh
<sa*********@gmail.comwrote:
>>Eric Sosman wrote:
>>printf ("Number, please? ");
fflush (0);
>>Can you tell me why you're using 0 instead of stdout?

$ man fflush
When calling fflush, if stream is a null pointer, all files open
for writing only and all files open for update whose last operation
was a write are flushed.
That means fflush(0) is valid, not that it's a good idea. In this case, I
don't see the benefit to fflush(0) either, so I'm also curious for the
reason behind it.
Jun 27 '08 #8
Walter Roberson wrote:
In article <g2**********@registered.motzarella.org>,
santosh <sa*********@gmail.comwrote:
>Eric Sosman wrote:
>>printf ("Number, please? ");
fflush (0);
>Can you tell me why you're using 0 instead of stdout?

$ man fflush
When calling fflush, if stream is a null pointer, all files open for
writing only and all files open for update whose last operation was a
write are flushed.
"What he said." And my purpose was obfuscatory deviltry,
with a sneaking hope that it might survive all the way into
the O.P.'s homework submission, where it would likely elicit
santosh's question from the O.P.'s instructor and cause him
a well-deserved dose of embarrassment ...

--
Er*********@sun.com
Jun 27 '08 #9
Eric Sosman <Er*********@sun.comwrites:
Walter Roberson wrote:
>In article <g2**********@registered.motzarella.org>,
santosh <sa*********@gmail.comwrote:
>>Eric Sosman wrote:
>>>printf ("Number, please? ");
fflush (0);
>>Can you tell me why you're using 0 instead of stdout?
$ man fflush
When calling fflush, if stream is a null pointer, all files open for
writing only and all files open for update whose last operation was a
write are flushed.

"What he said." And my purpose was obfuscatory deviltry,
with a sneaking hope that it might survive all the way into
the O.P.'s homework submission, where it would likely elicit
santosh's question from the O.P.'s instructor and cause him
a well-deserved dose of embarrassment ...
Which won't happen now that you've admitted it in public. Oh, well.

Next time, consider fflush(L'\0').

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 27 '08 #10
Eric Sosman wrote:
Walter Roberson wrote:
>santosh <sa*********@gmail.comwrote:
>>Eric Sosman wrote:

printf ("Number, please? ");
fflush (0);

Can you tell me why you're using 0 instead of stdout?

$ man fflush
When calling fflush, if stream is a null pointer, all files
open for writing only and all files open for update whose
last operation was a write are flushed.

"What he said." And my purpose was obfuscatory deviltry, with
a sneaking hope that it might survive all the way into the
O.P.'s homework submission, where it would likely elicit
santosh's question from the O.P.'s instructor and cause him a
well-deserved dose of embarrassment ...
An elegant objective, and quite possibly achieved, since the guilty
student has not reappeared, and so may have taken your method and
submitted it.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
** Posted from http://www.teranews.com **
Jun 27 '08 #11
On Jun 11, 11:44 am, sameer <pawan.prajapati...@gmail.comwrote:
1-develop a flowchart and then write a c program to display all prime
number less than the number entered by the user.
Try Sieve of Eratosthenes.
http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
<weird>
You are using this as a homework forum and everyone is responding.
</weird>
Jun 27 '08 #12
rahul wrote:
On Jun 11, 11:44 am, sameer <pawan.prajapati...@gmail.comwrote:
>1-develop a flowchart and then write a c program to display all prime
number less than the number entered by the user.

Try Sieve of Eratosthenes.
http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
<weird>
You are using this as a homework forum and everyone is responding.
</weird>
As a wise Narn said, "not all replies are answers".

--
"I am trying to say that you have no choice." /The Courts of Chaos/

Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England

Jun 27 '08 #13
On 11 Jun 2008 at 6:44, sameer wrote:
1-develop a flowchart and then write a c program to display all prime
number less than the number entered by the user.
#include <stdio.h>
#include <gmp.h>

int main(int argc, char **argv)
{
int status=0;

if(argc>1) {
mpz_t n,p;
mpz_init_set_si(p, 2);
if(mpz_init_set_str(n, argv[1], 10)==0) {
while(mpz_cmp(p, n) <= 0) {
mpz_out_str(stdout, 10, p);
puts("");
mpz_nextprime(p,p);
}
} else {
fputs("Invalid argument\n", stderr);
status=1;
}
mpz_clear(n);
mpz_clear(p);
} else {
fprintf(stderr, "Usage: %s n\nPrints the primes <= n\n", *argv);
status=2;
}
return status;
}

Jun 27 '08 #14
Don
On Jun 11, 1:44*am, sameer <pawan.prajapati...@gmail.comwrote:
1-develop a flowchart and then write a c program to display allprime
number less than the number entered by the user.
#include <stdio.h>

/* This program implements a blindingly fast O(n^n) algorithm
to find prime numbers, using an elegant recursive method. */
int _(int n, int m, int d, int t=0)
{
int r;
if (t) return d?1+_(n,m,d-1,d):n?_(n-1,m,m,n):0;
for(r=m!=n; d*(t<n); ++t)
r &= _(n,_(t,m,0,1),d-1)|!_(t,1,t);
return r*n;
}
/*------------------------------------------
Print primes up to the requested value
--------------------------------------------*/
int main(int argc, char* argv[])
{
int n,m;
scanf("%d",&m);
for(n = 2; n <= m; n++)
printf("%d is%s prime\n",n, _(n,1,n,0)?"":" not");
return 0;
}
Jul 9 '08 #15
Don <do*******@gmail.comwrites:
On Jun 11, 1:44Â*am, sameer <pawan.prajapati...@gmail.comwrote:
>1-develop a flowchart and then write a c program...
int _(int n, int m, int d, int t=0)
This is not C (though that may be deliberate given the context).

--
Ben.
Jul 9 '08 #16
Ben Bacarisse wrote:
Don <do*******@gmail.comwrites:
>On Jun 11, 1:44 am, sameer <pawan.prajapati...@gmail.comwrote:
>>1-develop a flowchart and then write a c program...
>int _(int n, int m, int d, int t=0)

This is not C (though that may be deliberate given the context).
Of course is not C, but lcc-win supports that!

:-)

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Jul 9 '08 #17
jacob navia wrote:
Ben Bacarisse wrote:
>Don <do*******@gmail.comwrites:
>>sameer <pawan.prajapati...@gmail.comwrote:

1-develop a flowchart and then write a c program...

int _(int n, int m, int d, int t=0)

This is not C (though that may be deliberate given the context).

Of course is not C, but lcc-win supports that!
That sounds like a bug. How do you get lcc-win to report the error?

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
Jul 9 '08 #18
CBFalconer <cb********@yahoo.comwrites:
jacob navia wrote:
>Ben Bacarisse wrote:
>>Don <do*******@gmail.comwrites:
sameer <pawan.prajapati...@gmail.comwrote:

1-develop a flowchart and then write a c program...

int _(int n, int m, int d, int t=0)

This is not C (though that may be deliberate given the context).

Of course is not C, but lcc-win supports that!

That sounds like a bug. How do you get lcc-win to report the error?
It's obviously an extension.

If lcc-win's conforming mode works correctly, it will issue a
diagnostic. In the absence of any evidence that it doesn't, I suggest
that speculating about *possible* bugs in lcc-win (or any other
compiler) is both off-topic and a waste of time. (Which is not to
imply that mentioning the extension in the first place was topical.0

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 10 '08 #19
On Jun 11, 2:44*pm, sameer <pawan.prajapati...@gmail.comwrote:
1-develop aflowchartand then write a c program to display all prime
number less than the number entered by the user.
You can try AutoFlowchart! http://www.ezProg.com
-----------------------------
AutoFlowchart is a excellent source code flowcharting tool to
generate flowchart from source code. Its flowchart can expand and
shrink. and you can pre-define the the width , height,Horizontal
spacing and vertical spacing. Move and zoom is also very easy. It can
export the flowchart as a Microsoft Visio,Word file or a bitmap file.
It can help programmers understand, document and visualize source
code.
It supports C,C++,VC++(Visual C++ .NET),Delphi(Object Pascal).
Maybe it can help you!
-----------------------------
auto generate flowchart from sourcecode
export the flowchart as Ms Visio file
export the flowchart as Ms Word file
expand and Shrink the flowchart
pre-define the base size of the flowchart block
zoom and move the flowchart freely
export the flowchart as a bitmap

Jul 15 '08 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kelvin | last post by:
hi: im looking for a tool that can help me to draw a flowchart... is there such tool? thank you very much... -- { Kelvin@!!! }
0
by: mida | last post by:
i want to create flowchart/flowdiagram like msword.And the user type inside the rectangular what they want to do...plz help me ...i need the source code ----------------------------- This message...
1
by: JackieR | last post by:
I have taken over a project and would like to flowchart the entire solution. I have found flowchart programs that work on a single .cpp file, but nothing for the entire project. Does anyone know...
3
by: VJ | last post by:
Hello Group, I am working on a project to derive a flow chart from a c program. Can any one please help me on what tools/methods i need to use. thanks
5
by: Jaswant Singh Rana | last post by:
HI all, Is it possible to generate a flowchart on the fly in a web page? The chart will be based on the coordinates stored in a table or xml file. Jaswant Singh Rana
0
by: - | last post by:
Is there a flowchart symbol for 'try' and 'catch'? I am reading a value from the command line by calling a method that throws a NumberFormatException. Should I draw the flowchart similar to...
3
by: Paulers | last post by:
hello everyone, can anyone recommend a free flowchart framework for vb.net? I was drooling over Flowchart.net until I saw the $500.00 price tag. I realize that a lot of work went into...
19
by: William Gill | last post by:
I seem to be having a mentally bad period lately . My code is beginning to be terrible convoluted mess, and I shudder to think what it will be like to go back in a couple months and try to follow...
2
by: stuckagain | last post by:
Hi, I am drawing a cross-functionality flowchart, to document the process between 2 disjointed software systems. The first system can initiate functionality in the second, and the second system...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.