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

In summary: So, if everything's still unclear, you might want to try looking online for more specific, step-by-step instructions on how to write basic C programs. 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 bracketswhy 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
  • #1
Niaboc67
249
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
  • #2
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.
 
  • #3
Please give a specific one to do. One you think would be good for a beginner C project.
 
  • #5
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.
 
  • #6
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!
 
  • #7
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 Medicol and mafagafo
  • #8
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 Medicol
  • #9
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 Medicol

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

1. What is C and why is it important to learn?

C is a programming language that was originally developed in the 1970s and is still widely used today. It is important to learn because it is a high-level language that allows for efficient and low-level control of computer hardware, making it useful for tasks like operating systems and device drivers.

2. What are the basic concepts of C that I should know before starting a project?

Some basic concepts of C include data types, variables, control structures, and functions. It is also important to understand pointers, which are a key feature of the language.

3. How can I get started with a basic C project?

A good way to get started with a basic C project is to first familiarize yourself with the language's syntax and basic concepts. Then, choose a simple project idea, such as creating a calculator or a program that prints out a message. You can find tutorials and resources online to guide you through the process.

4. Are there any specific tools or software I need to use for a C project?

To write and run C programs, you will need a text editor and a compiler. Some popular options include Visual Studio Code, Atom, and Code::Blocks. You can also use online compilers for simple projects.

5. How can I improve my skills in C and take on more advanced projects?

The best way to improve your skills in C is to practice and work on more challenging projects. Joining online communities and forums can also help you learn from others and get feedback on your code. Additionally, reading books and taking online courses can provide a more structured learning experience.

Similar threads

  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
2
Replies
49
Views
3K
  • Programming and Computer Science
Replies
2
Views
857
  • Programming and Computer Science
Replies
10
Views
1K
Replies
6
Views
1K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
Replies
11
Views
1K
  • Programming and Computer Science
Replies
17
Views
4K
  • Programming and Computer Science
Replies
28
Views
3K
Back
Top