Could someone give me a basic lesson/project to do in C

  • Thread starter Thread starter Niaboc67
  • Start date Start date
  • Tags Tags
    C programming
Click For Summary

Discussion Overview

The discussion revolves around finding a suitable beginner project or lesson in the C programming language. Participants explore various project ideas and express their experiences and challenges in learning C, including specific programming concepts and syntax.

Discussion Character

  • Exploratory
  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant seeks a beginner-friendly project in C to gain practical experience.
  • Another participant suggests using Project Euler for exercises, providing a link to a specific problem.
  • A different participant proposes a custom project to print all positive integers less than or equal to 200 that are multiples of 3 or 5, questioning if this is appropriate for a beginner.
  • A participant expresses their lack of understanding of basic C syntax and concepts, such as the purpose of #include , the structure of the main function, and the meaning of return 0.
  • Some participants advise the original poster to study C syntax independently and suggest that learning C may be challenging for complete beginners compared to other languages like Python.
  • One participant points out that the declaration of an unused variable in the "hello world" program is redundant and provides a minimal version of the program.

Areas of Agreement / Disagreement

There is no consensus on a specific project that is suitable for a complete beginner. Participants express differing views on the appropriateness of suggested projects and the best approach to learning C.

Contextual Notes

Some participants highlight the importance of understanding basic syntax and concepts before attempting projects, indicating that the original poster may need to build foundational knowledge first.

Niaboc67
Messages
249
Reaction score
3
I know there are many resources online for this but I'd to learn from someone on here. Could you provide me a lesson/project to do and finish in C language for beginners. I can get the software needed to compile and such and will post an image when I am done or provide whatever proof of completion needed. I just need a beginner lesson to get my feet wet in C.

THANK YOU
 
Technology news on Phys.org
https://projecteuler.net/ Has tons of great exercises for novice programmers. You can do some of these exercises and then ask questions about your code here. Just put your source on www.pastebin.com and post the link here.
 
Please give a specific one to do. One you think would be good for a beginner C project.
 
DavidSnider said:
This might be too hard for someone who is just a beginner at C.

Here's an easier one that I made up after looking at problem #1 in the Project Euler problems.

Print all of the positive integers <= 200 that are multiples of 3 or 5. The first few numbers in the output should be 3, 5, 6, 9, 10, and so on.

Let us know if that's too easy for you.
 
I should point out that I am very new to this but want to learn more and more about C.

And no that project is not easy for me.
I was able to make the basic "hello world" program, when searching the web

#include <stdio.h>
int main()
{
int num
printf("hello world")
return 0;
}

SEZfAQP.png

So I was able to compile just fine.
However, even that I don't fully understand what's going on to make it print out Hello World.
Why #include <stdio.h> what is that? what does it mean?
Why int main()?
why the brackets
why int num;?
Print makes sense as it's the purpose of the program. but why f? and why return 0;
Is that sort of like saying there is nothing more to do here.
I think I understand the brackets as to mean Opening and Closing of a program/function/operation?

Why does any of that exist and in that order?
And could I have a hint for the program asked not sure how to go about it

THANK YOU!
 
Niaboc67 said:
However, even that I don't fully understand what's going on to make it print out Hello World.
Why #include <stdio.h> what is that? what does it mean?
Why int main()?
why the brackets
why int num;?
Print makes sense as it's the purpose of the program. but why f? and why return 0;
Is that sort of like saying there is nothing more to do here.
I think I understand the brackets as to mean Opening and Closing of a program/function/operation?

Why does any of that exist and in that order?
And could I have a hint for the program asked not sure how to go about it

THANK YOU!
You are asking us to answer all of the basic questions about language syntax. You need to study this stuff on your own. LOOK UP what they each mean and do and then apply them in VERY simple cases to make sure you understand them, and then come back with questions that you still have.
 
  • Like
Likes   Reactions: Medicol and mafagafo
It will take an inordinate amount of time and effort to learn a programming language by "searching the web", especially if, as I suspect the case is here, it is your first programming language, when this will most likely simply fail. Get a book. Or find a tutorial on the web. Either way, stick with it and follow it methodically. Do not go for random examples.
 
  • Like
Likes   Reactions: Medicol
Niaboc67 said:
I should point out that I am very new to this but want to learn more and more about C.

This begs the question: why are you learning C in the first place? If you're learning out of personal interest and you're new to programming in general, you're probably better off starting with a more beginner-friendly language like Python. The "hello, world" program in Python is just one line long:

Python:
print("hello, world")
I was able to make the basic "hello world" program, when searching the web

#include <stdio.h>
int main()
{
int num
printf("hello world")
return 0;
}

As phinds pointed out above, most of the questions you asked about this program would be fairly quickly answered if you read a good book or tutorial on C, which you should really be doing anyway if you want to learn C.

There's just one exception that's worth mentioning to save you any future confusion: the "int num;" line in your example program is redundant. It declares an integer variable that the program never uses. The minimal "hello, world" program in C is just

C:
#include <stdio.h>

int main(void)
{
    puts("hello, world");
    return 0;
}
 
Last edited:
  • Like
Likes   Reactions: Medicol

Similar threads

  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 49 ·
2
Replies
49
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
Replies
6
Views
3K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 17 ·
Replies
17
Views
5K
  • · Replies 28 ·
Replies
28
Views
4K
  • · Replies 9 ·
Replies
9
Views
2K