473,765 Members | 2,035 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2494

vu*****@gmail.c om 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.c om 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.c om 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.c om 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.c om 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.c om 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_Keit h) 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*****@invali d.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.Be dBuG.pAlS.INVALID | sed s/[[:upper:]]//g`
Mar 3 '06 #9
S.Tobias said:
Richard Heathfield <in*****@invali d.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

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

Similar topics

0
320
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
1414
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 lack of a unified content strategy. But things are changing at Decibel. The magazine recently adopted a new approach to creating, managing, and delivering content to its customers. In this exclusive interview with TheContentWrangler.com,...
0
1350
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 your feedbacks. Thanks!
1
1347
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 subscriber first lesson on the day of subscription
4
2466
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 an easy way to assign one or multiple lessons to a student. tbl_Students
1
1479
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
1390
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 lessons for management students. They are in no way, a replacement for the classroom lectures, textbooks or any other study guides. If you wish to go through these lessons. Please visit today's BLOGS:
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10163
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9957
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8832
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.