C Problems and Solutions [closed] - c

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm looking for a series of C problems (with solutions) that I can use to build my C skills. I already understand the basics of the language, the syntax, and the semantics. I am looking for a series of problems that will help me hone my skills, not a set of simple questions that you'd see in an introductory programming class.

You might try solving some of the problems on Project Euler. The first few are pretty simple, but they get very challenging very quickly. I think it's a lot of fun trying to come up with the shortest code or highly optimized code to compute the results (though, I generally use C++ or Python, not C).
One advantage the Project Euler problems have is that they aren't just language-centric; they're problems that really make you think hard about how to develop an elegant solution to difficult problems.

And don't forget code-golf.
You probably want to respond only to challenges (questions) that have at least 10 upvotes.

Here is a list of sites with online judges (and similar) which contains a large variety of problems:
(The sites are sorted in lexicographical order)
ACM Live Archive, problems from past ACM/ICPC regionals and World Finals.
Arbiter, online judge at Sharif University in Iran.
FZU Online Judge
Google Code Jam
Harbin Online Judge
Hangzhou Dianzi University (HDU) Online Judge
Hunan University ACM/ICPC Online Judge
IPSC (Internet Problem Solving Contest)
KSRU Online Judge
10.Jilin Online Judge
11.Lviv Online Judge
12.Moscow Online Judge
13.National Taiwan University Online Judge
14.Online Problems Solving System (OPSS)
15.Peking University Online Judge
16.Programming Challenges
17.Project Euler
18.Saratov Online Judge
19.Sphere Online Judge
20.TJU Online Judge
21.TopCoder
22.Ural Online Judge
23.USACO Training Program Gateway
24.UVa Online Judge
25.Wuhan University Online Judge
26.ZJU Online Judge
27.Z-Trening

Build libraries that implement sophisticated data structures, like binary trees, dictionaries, and such.

Write a compiler. It doesn't need to be complex or even complete: you can make up a simple language (a subset of lisp?) and then write a lexer for it. Make sure you start by laying down the formal grammar. You will touch memory management, pointer arithmetics and other neat C stuff.
I learnt a great deal about automata and compiler-design by writing a simple YAML parser in C++.

Try out Dennis Ritchie's book on C programming language. The book has quite good problems and also reading it is a joy :)
For more challenging problems you can go to Bitwise Programming contest

Ruby Quiz has 156 problems with solutions. But in Ruby, not C. See the ruby-lang mailing list for more after James stopped being Ruby quiz master.

Knuth's repository of bitwise stuff might help in the noble pursuit :)
http://www-cs-faculty.stanford.edu/~knuth/fasc1a.ps.gz

Practice code Katas, language does not matter that much. Trying to solve Katas you allready did with another language is usually quite efficient to learn a new language.

You could always visit Freshmeat, find a few projects that interest you and look at their bug tracker. Grab the code and try to fix a few of the problems.
This helps open source while also helping you to get used to jumping in to someone else's code with debugging goggles on.

Related

Are there good tutorials for SDL2.0 for C programming? (not C++) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm a student learning C programming (at the moment).
In the subject I was given, I have to create some kind of Wolfenstein3d clone (hence the name of the project, "wolf3d"). To do this project, I'm allowed to use either the graphic library created by my school, or the SDL. I chose the SDL, because it is more complex to use and therefore more interesting.
Unfortunately, I was not able to find any tutorial for SDL2 in C. Even the SDL wiki links were all oriented C++.
I'd be grateful if you could help me finding good tutorials for the SDL2 in C (even though I know the policy of the website is "use a search engine, which I did, but as I said, I did not find any so far).
I think I might need to explain a few things about my school, in order to not give you the impression I'm asking you for help in order to cheat:
Why don't you look in your class notes?
Because I'm not given any. I'm given projects to do and sometimes few hints as how I should do them. I'm supposed to use Google or any means as long as I understand what I did.
And that's pretty much it. I'm also not looking for a tutorial on "how to create a wolfenstein3d clone using SDL2.0", but only a tutorial on how to use the SDL2 itself, from creating a window to drawing points.
If I were you I would use the tutorials available on SDL's page here:
http://wiki.libsdl.org/Tutorials
In conjunction with the API documentation here:
http://wiki.libsdl.org/APIByCategory
The API is written in C so despite the fact that the tutorials may be in C++ you should be able to follow the tutorial by referencing the API docs and understanding the functional structure of the example programs.
As an aspiring developer you should be able to understand enough of the C++ syntax to understand the conceptual way you need to develop an analogous application in C. The API calls will be need to made in the same way.
Consider this page from one of the linked tutorials (which is stated as being for C++):
http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index2.php
Are any of those code blocks really foreign to you? They shouldn't be, they're written in C. If you come across some expressions you are unfamiliar with as you go through the tutorial, reference the API. If you're still stumped, then maybe it would be time to post on StackOverflow. That particular tutorial may be written completely in C, I'm not sure I only went through the first few pages.
Also note that the function documentation in the SDL API docs gives C and C++ example code:
http://wiki.libsdl.org/SDL_Init
Here you can cross reference two identical programs in C and C++ and begin to learn how the same operations are performed in the two languages. From there you can start to interpret C++ tutorials for high level functional operations and translate that to C as opposed to just copying code samples. You will learn much more going through this process.
To your own admission you decided to go the complex route. You should be prepared to invest some effort in the process!

Getting started with the sport of competitive programming [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
How do you get started with competitive programming and get well versed with various topics in it ?
What all things you can do ?
Get started directly or do some concepts first.
This is a very popular question on Quora, but is generally considered off-topic for Stack Overflow. The best way to use SO for competitive programming advice is to ask specific questions about problems you're having when coding a solution. For example, you might ask how a language feature works. Often you'll find that the question has already been asked.
Here are the 108+ Quora answers to your question: https://www.quora.com/How-do-I-become-a-competitive-programmer
The summary answer is: Get started solving problems. If you have any programming background, which I'm sure you do since you're asking this question, you'll get more benefit from just starting rather than reading a lot first. When you get stuck on something, that's the time to read books or online resources.
If you're having trouble deciding what to start on, here's a suggestion from my blog of how I would get started: http://www.redgreencode.com/about-project-462/
My 2 cents...
Best option is to get registered at the following coding sites..
+ topcoder.com
+ codechef.com
+ hackerrank.com
And, while you hack code here, you can build upon your programming foundation by learning more on
+ Data structures
+ Algorithms
+ Operating system concepts
+ Networking concepts and more ...
You could also start looking at the following books in this area...
+ The Algorithm Design Manual
+ Programming Challenges: The Programming Contest Training Manual
+ Competitive Programming 2
My advice would be to get registered with a Competitive Programming site if you know how to write simple codes in a particular programming language and solve the basic problems(the ones which does not require algorithms or require basic ones).
My suggestion on the choice of site is:-
1)HackerRank:-https://www.hackerrank.com/
Problems are well categorized here.Practice the questions marked 'easy' here followed by a few 'medium' ones.Complete the '30 Days of Coding Challenge' that would give you a good basic idea of the Java language.Also, check other's code and the editorial even if your code passes all the test cases.
2)SPOJ:-
Practice the problems categorized under 'ad-hoc' here.Start by solving the problems which are solved by most people...usually they will be easier.
3)Start implementing basic(or standard) algorithms. It is suggested to read them from Topcoder tutorials or Introduction to algorithms.Also, follow a standard book along with it.Now, practice problems based on those algorithms until you get familiar with them.
4)After you get acquainted with the most common algorithms start competing in coding challenges.Practice makes you better. Try to solve problems from previous contests. Solve as many problem A-s as you can until they give you some trouble. Then move on to B, then C etc.
Hope it helps :)
P.S. Also check the following answer on Quora:-
https://www.quora.com/What-is-the-best-strategy-to-improve-my-skills-in-competitive-programming-in-2-3-months/answer/Sachin-Gupta-6?srid=4gZ6

How "Hello World" works in C [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am searching for a month for blog posts about "how C program works". Most of them go like
Compilers do these things
Linkers do these things
Program is put into memory; and stacks, heaps, etc.
I thought I would first read about how compiler works to understand the flow of the program into the machine. Dragon Book seems to be universally preferred. But truthfully, it's too intensive. I am not good enough now to go through it all.
So I began to read about hardware. But There too, they explain about buses, I/O signals, structure of memory, writing cache-friendly code etc. But with no proper examples.
But still I could not find myself satisfied or being able to completely visualize the process.
2 hours ago I decided to ask this question.(Since I am scared of It might be not useful to SO community, or off-topic question or other down-votable categories) and I did not find out any post relating to this exactly. There was one about "how compiler does the compilation", but the answers showed that it's too broad a question.
My question is this:
I would like to know how, in depth, a C program works. If you cannot tell me explicitly, please redirect me to a book or another post on another website that can give me the answer to this.
I am here until I get a response. If you have any suggestions regarding this post, tell me. And It is not my first language, so please take all my sentences as being soft and polite.
Thanks.
UPDATE:
Along with the accepted answer, there are some very nice links as well as suggestions which give partial answers or the way to proceed further to understanding what I am trying to understand.
The best answer to this question by far comes from the book "The Elements of Computing Systems," by Noam Nisan and Shimon Schocken. This book starts from the simplest possible electronic components, assembles them into a working processor, invents a simple assembly language for it, writes an assembler for that, and ultimately shows you how high-level languages can be compiled onto it. Reading the book, and working all the examples (which use a simulator for the hardware, so no workshop required!), will forever change the way you look at computers; he will literally understand everything from the lowest to the highest levels, and see how they work together. See the book's website for more info.
It's too broad a question (as you have observed).
If you really want to understand from bottom up - buy an OLD computer from the 80's off ebay. Sinclair Spectrum/BBC it really doesn't matter but make sure you get plenty of books and manuals that go with it.
You will learn plenty because these machines were well documented and what wasn't documented was discovered and then documented :)
They are also sooooo much simpler than a modern quad core multi-gigabyte memory job. It will all fit inside your head easily
or for a modern start, Arduino or Raspberry pie maybe.

Best online source for learning C [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Im an experienced actionscript developer, and relatively new to Objective C.
I decided a good investment of my time would be to master the C language (not C# or C++).
Can anyone recommend the 'best' online tutorials for learning C?
You won't have difficulties understanding the C syntax given your past experience, and unfortunately, most tutorials and introductory books will focus on it much more than they should.
C is full of traps, but it is a simple language which gives you full control on what is going on with your programs. However, it is difficult to master. You will need something more elaborated than a simple tutorial which will be half full of things you probably already know.
I definitely recommand K&R's book if you want to learn the language correctly. Be sure to grab the second edition.
I agree with James' comment, though I would recommend looking over the first paragraphs of a web based tutorial.
Though they're not the best for learning the language itself, you can get a feel for some trivial programs and see if they fit your brain.
The worst thing that can happen here is if you buy a book and can't use the language (for whatever reason).
As far as specific selections... I can't give you any.
As you've asked for online resources only, so here is one
http://www.cprogramming.com/tutorial/c/lesson1.html
Like Alexandre , I would also recommend K & R's book
You should check this out too:
http://www.phy.duke.edu/~rgb/General/c_book/c_book/index.html
I've looked through it, it's got some good examples and it's a good read.

Resources for learning C, Unix, Linux and embedded systems [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I want to learn C , UNIX and LINUX, and more about embedded systems. Very much interested in them. Are there any online courses or websites which can guide me. And please suggest books to read in learning them.
Thanks for your time.
Ya please lets your answers and comments come in , they are invaluable to me..!!
The C Programming Language by K & R
Advanced UNIX Programming
UNIX Network Programming
Structure and Interpretation of Computer Programs Videos (done in LISP, but invaluable programming course)
Understanding the Linux Kernel (a little out of date but good info, don't take as gospel)
Linux Device Drivers 3rd Edition (pretty out of date but good info, same as above)
Writing Linux Device Drivers (pretty up to date but not as detailed as before)
The UNIX Time-Sharing System, this is essentially the original UNIX paper, it may help to understand where all this came from, don't have to understand every detail of this old paper but I think it gives some good background
I'd highly recommend "UNIX for dummies" as a starting point on Unix/Linux.
There are many amazing resources online. My favorite is from MIT.
http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/
Free courses. They can be pretty in depth, and cover many more subjects than just computer science and mathematics.
Few resources that helped me for C:
The C Programming Language Book by K & R
highercomputingforeveryone.com helped me out initially
Stanford's Programming Paradigm Videos
Good Luck!
A quick way to learn a bit about all of the above is to buy an MSP430-based development board from Texas Instruments, install mspgcc (the open-source compiler for the MSP430) on a Linux machine, and write a basic C program that blinks an LED on the development board.
Other than the resources suggested above, you need to understand why you need these languages. Programming language or an OS alone will only take you as far -- for e.g. if you are programming on embedded platforms usually memory is not in abundance. So you need to code for memory optimization. If you are working on real time, you would need to understand interrupt handling well etc. I'd suggest definitely spend time on the architecture (ARM Cortex-M1 etc) for which you are planning to code. Always helps.
For more quirks look into http://en.wikibooks.org/wiki/Embedded_Systems/C_Programming
Orielly's Programming Embedded Systems in C and C++ is a good place to start once you have the basics of C/C++ clear.

Resources