473,387 Members | 3,821 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,387 software developers and data experts.

C Lessons Project

Learn C programming from these daily lessons I found. They're eleven
days ahead of you already so get busy...

http://www.visualcmaniac.com

Mar 3 '06 #1
10 2448

vu*****@gmail.com wrote:
Learn C programming from these daily lessons I found. They're eleven
days ahead of you already so get busy...

http://www.visualcmaniac.com
DON'T! Unless you want to learn how to write *bad* C-like programs.

And here's why ("Lesson" 12):
#include <stdio.h>
#include <math.h>
Not necessary to include math.h as it's not used below
void main() {
After this, all bets are off. Watch pink pigs crawl out your ears
(undefined behaviour, `main` has to return `int`).
int i, n, prime=1; // prime is true
Comments like these are OK in C99.
printf("Input natural number :");
Not terminating `printf` with \n makes it possible for the
implementation to NOT print anything out (at least not before firts \n
it sees).
scanf("%d", &n);
No error checking. What if user enters something that's not an integer.
Even if integer is entered, what if it's negative?
for( i=2; i<= n-1; i++) {

if( n % i == 0 ) { // also possible to state if(!(n % i))
Much better to parenthesise appropriatelly:

if( (n % i) == 0 ) { // also possible to
state if(!(n % i))
prime =0; // prime is now false
break;

}
}

if( prime )

printf("%d is prime number !\n", n);

else

printf("%d isn't prime number!\n", n);

}


Spacing is atrocious (or sloppy, if you will).

I didn't check whether the algorithmu used is actually correct either.

Mar 3 '06 #2
vu*****@gmail.com said:
Learn C programming from these daily lessons I found. They're eleven
days ahead of you already so get busy...

http://www.visualcmaniac.com


If these lessons are supposed to teach C, they fail. If they are supposed to
teach some platform-specific variant of C, they are off-topic here.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Mar 3 '06 #3
Vladimir S. Oka wrote:
vu*****@gmail.com wrote:
Learn C programming from these daily lessons I found. They're eleven
days ahead of you already so get busy...

http://www.visualcmaniac.com
Comments like these are OK in C99.
printf("Input natural number :");


Not terminating `printf` with \n makes it possible for the
implementation to NOT print anything out (at least not before firts \n
it sees).


<snip>

Could you explain this please ... seems like you're saying that, say,

printf("Enter a number >");

might result in printf not outputting anything?

--
==============
*Not a pedant*
==============
Mar 3 '06 #4
pemo said:
Could you explain this please ... seems like you're saying that, say,

printf("Enter a number >");

might result in printf not outputting anything?


Right, because stdout is typically line-buffered.

fflush(stdout); will ensure that the display occurs even without the
newline.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Mar 3 '06 #5
vu*****@gmail.com wrote:
Learn C programming from these daily lessons I found. They're eleven
days ahead of you already so get busy...

Oddly, the lessons you "found" seem to have been posted by someone
named Vurdlak. That's your name too! What a coincidence.

Brian
Mar 3 '06 #6
vu*****@gmail.com wrote:
Learn C programming from these daily lessons I found. They're eleven
days ahead of you already so get busy...

http://www.visualcmaniac.com

I had a brief look at this site - and, trying to be as gentle as I find I
can be - well, it *suckie*
--
==============
*Not a pedant*
==============
Mar 3 '06 #7
vu*****@gmail.com writes:
Learn C programming from these daily lessons I found. They're eleven
days ahead of you already so get busy...

http://[snip]


I don't think I've ever seen an "I've found this web site" posting
where the poster isn't actually the author of the web site. Sure
enough, every entry was posted by someone named "Vurdlak".

Lying to us about your own web site isn't a good start.

Filling your site with bad code and system-specific assumptions
doesn't exactly impress me either.

Learn C before you try to teach it.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 3 '06 #8
Richard Heathfield <in*****@invalid.invalid> wrote:
pemo said:
Could you explain this please ... seems like you're saying that, say,

printf("Enter a number >");

might result in printf not outputting anything?
Right, because stdout is typically line-buffered.

fflush(stdout); will ensure that the display occurs even without the

^^^^^^^^^^^ newline.

^^^^^^^

On my line printer too?

--
Stan Tobias
mailx `echo si***@FamOuS.BedBuG.pAlS.INVALID | sed s/[[:upper:]]//g`
Mar 3 '06 #9
S.Tobias said:
Richard Heathfield <in*****@invalid.invalid> wrote:
pemo said:
Could you explain this please ... seems like you're saying that, say,

printf("Enter a number >");

might result in printf not outputting anything?


Right, because stdout is typically line-buffered.

fflush(stdout); will ensure that the display occurs even without the

^^^^^^^^^^^
newline.

^^^^^^^

On my line printer too?


Sure. To demonstrate this, I have omitted to place a newline on the next
Mar 3 '06 #10
pemo wrote:
Vladimir S. Oka wrote:
vu*****@gmail.com wrote:

.... snip ...
printf("Input natural number :");


Not terminating `printf` with \n makes it possible for the
implementation to NOT print anything out (at least not before
firts \n it sees).


<snip>

Could you explain this please ... seems like you're saying
that, say,

printf("Enter a number >");

might result in printf not outputting anything?

==============
*Not a pedant*
==============


Exactly. However explanations require pedantry, so we won't
inflict that on you.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
Mar 4 '06 #11

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

Similar topics

0
by: vurdlak | last post by:
Learn C programming from these daily lessons I found. They're eleven days ahead of you already so get busy... http://www.visualcmaniac.com
6
by: Scott Abel | last post by:
Decibel, the underground hard rock and extreme heavy metal magazine, had the same problems as many other content-heavy organizations: inefficient and disconnected processes, outdated tools, and the...
0
by: Narko | last post by:
Symfony Lessons I propose self-written free Symfony framework lessons for everyone: http://narkozateam.com/symfony/ If you want to know more about PHP, AJAX, MVC - take a look there and give me...
1
by: Sebastian Spandauer | last post by:
Hey, i am searching for a php script that features sending a lets say 20 lesson online course. it should: subscription on website opt-in after subsriciption send one lesson per day to every...
4
by: Dave White | last post by:
Hello Everyone, I have created two tables to track my students' lessons. Each student is responsible for most, but not all. of the lessons. I've tried a junction table but I can't figure out...
1
by: rugomoka | last post by:
Hi I am kindly requesting you to avail me with chronological lessons about designing a web site(from lesson- to last lesson.
0
by: delhi institute of management & services | last post by:
Delhi Institute of Management & Services Dear friends, We are extremely happy to welcome you to the world of Management... We are in the process of preparing some 5 minutes revision Q & A type...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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.