fbpx
Home Blog Page 288

11 C++ Code Challenges for Beginners

0
11 C++ Code Challenges for Beginners

Learning C++ is no small feat, but keeping all your new skills fresh requires practice. It’s one thing to learn about code fundamentals and syntax, but it’s an entirely different thing to use that knowledge to create C++ programs.

In this article, we’ll describe where you might use C++ in your next job and why it’s such a powerful programming language. To save you time looking for ways to practice putting C++ to work, we’ve got 11 code challenges for beginners that you can dive right into.

Learn something new for free

What is C++ used for?

C++ is one of the most widely used programming languages. So, a better question might be, what isn’t C++ used for?

Most often, C++ is selected because of its ability to run large applications efficiently. You can also use it to fine-tune how a program uses its hardware. You can find C++ within operating systems, your favorite multiplayer games, powering databases, and even in emerging VR and AR technologies.

Many developers choose C++ because it can efficiently run their programs, even on relatively small hardware provisions. But they also like using the language because so many other developers are familiar with it, allowing for easier collaboration and getting help when you get stuck. In another post, we take a closer look at what C++ is used for.

11 C++ code challenges for beginners

While you were taking courses on C++, you may have used a built-in editor to complete your assignments. If that’s what you’re most comfortable with, then try these challenges in that editor. But, if you’re interested in challenging yourself to use an editor on your local machine, you can execute these challenges there too.

The main goal of these challenges for beginners is to keep you going. So, choose the editor that works best for you and set yourself a target. Maybe it’s completing one code challenge each day. Maybe it’s a challenge every weekend. Whatever you pick, make it realistic and schedule it into your calendar to make it a priority.

1. Print out a “Greetings!” message

In whichever editor you’ve chosen to work with, see if you can write a piece of code that displays a string. While this might be a simple task, think of all the ways you’ll want to display messages in future programs you create.

Printing error messages or confirmation messages for different pieces of code are important when you’re debugging a program. There may also be prompts or results you’ll want to print and share with the end-user.

Printing a message is a skill you’ll use quite frequently.

2. Create a program that adds two integers

See if you can create a C++ program that takes two integers and adds them together. The result should return the sum. While this may be a rudimentary calculator, imagine its power in a large database where you could use loops to add massive quantities of data very meticulously.

Bonus challenge: Expand on this program to add two columns of a matrix to produce an array of the summed elements.

If you’re interested in working in the financial industry as a developer, you’ll use programs like this to help your company calculate its figures.

3. Create a program that converts meters to feet

Unit converters are helpful little tools. Can you create a program in C++ that takes a measurement in meters and gives you the exact same measurement in feet as the answer?

If you’re considering a career in data science, you’ll need to be good at cleaning up and formatting data. Converting data to another unit of measurement is a good first practice test for your future role.

4. Program a temperature conversion tool

Similarly, converting temperature to another unit of measurement is a helpful program to build. See if you can create a program that takes inputted temperature in Celsius and returns the same temperature in Fahrenheit.

If you wanted to make this a more intermediate-level challenge, try making the input both a temperature and the unit of measurement. Have your conversion program return the same temperature but in the other units.

5. Calculate the perimeter of a rectangle

Similar to conversation tools, perimeter and area calculators are also helpful programs to know how to build. In this challenge, create a program that calculates the perimeter of a rectangle.

The perimeter of a rectangle is determined by the formula: P = 2 * (length + width), where length and width are the dimensions of the rectangle. Once you input the length and width of the rectangle, the program should then calculate its perimeter using the formula.

6. Create a floating-point multiplier program

Given two floating-point numbers, create a C++ program that gives you the product of the two.

Looking to take things up to an intermediate level? Build upon this challenge by allowing for any number of inputs (or an array of them) and returning the product of all input floating-point numbers.

7. Convert a string to all uppercase letters

You can decide how long or short your input string will be. This program should take inputted lowercase letters and convert them to uppercase.

Just like the challenge above that was well suited to data science, imagine how useful this tool could be for managing databases or cleaning data.

8. Create an average calculator

Write a C++ program that takes an array of numbers as its input and provides the average of the entries in return. If you wanted to build upon the array input, you could make another average calculator that takes a matrix as its input and provides the average of each row or column.

9. Create a function that trims a string down to 10 characters

Can you construct a function that accepts a string as input and returns a shortened version? There are many applications for data trimming, but consider how a tool like this would help eliminate errors in a database.

For example, in customer address data, any zip code greater than five characters would be incorrect. Trimming entires using a program like this can help keep databases clean.

10. Program an array sorter

Given an array of, let’s say, 10 numbers, can you create a program that returns the array in numerical order? Sorting data is a powerful way to use C++. If you’re comfortable with a small array, try working with a larger one — or even a matrix.

11. Create a program that counts duplicate array entries

While cleaning data, Data Scientists need to eliminate duplicate data. So, in this short code challenge, you’ll create a program that returns the number of elements in an array that are duplicates.

More ways to practice C++

There are many places you can find additional code challenges online, but you might already have plenty of options within reach. Along with these suggestions, go back into your C++ course notes and repeat the same exercises and assignments. Or, if you need a refresher, check out our Learn C++ course.

You can also contribute to open-source projects online if you’re looking to keep your C++ skills fresh. And no matter which option you choose, you’ll be preparing yourself for your next job and possible technical interview questions.

Remember, just do a little each day, keep your goals manageable, and have fun solving challenges with C++.

This blog was originally published in September 2021 and has been updated to include new beginner projects.


Whether you’re looking to break into a new career, build your technical skills, or just code for fun, we’re here to help every step of the way. Check out our blog post about how to choose the best Codecademy plan for you to learn about our structured courses, professional certifications, interview prep resources, career services, and more.

Bear in Pajamas

0
Bear in Pajamas

Use your imagination to write the opening of a short story or poem inspired by this illustration, or describe a memory from your own life that this image makes you think of.

Tell us in the comments, and then read the related article to learn more.


Students 13 and older in the United States and Britain, and 16 and older elsewhere, are invited to comment. All comments are moderated by the Learning Network staff, but please keep in mind that once your comment is accepted, it will be made public and may appear in print.

Find more Picture Prompts here.

Word of the Day: augment

0
Word of the Day: augment

The word augment has appeared in 119 articles on NYTimes.com in the past year, including on Jan. 6 in “Where to Find Great New York Slices in 2025? You Might Be Surprised” by Ed Levine. The article is about great New York-style pizza that can be found across the United States:

Mr. De Leon had been making pizza at restaurants in his East Los Angeles neighborhood since he was a teenager. He spent parts of the next 25 years making a living as a photographer, while moonlighting as a pizza maker when he needed to augment his income.

Can you correctly use the word augment in a sentence?

Based on the definition and example provided, write a sentence using today’s Word of the Day and share it as a comment on this article. It is most important that your sentence makes sense and demonstrates that you understand the word’s definition, but we also encourage you to be creative and have fun.

If you want a better idea of how augment can be used in a sentence, read these usage examples on Vocabulary.com. You can also visit this guide to learn how to use IPA symbols to show how different words are pronounced.

If you enjoy this daily challenge, try our vocabulary quizzes.


Students ages 13 and older in the United States and the United Kingdom, and 16 and older elsewhere, can comment. All comments are moderated by the Learning Network staff.

The Word of the Day is provided by Vocabulary.com. Learn more and see usage examples across a range of subjects in the Vocabulary.com Dictionary. See every Word of the Day in this column.

What Teens Are Saying About Age Limits for Anti-Aging Skin Care

0
What Teens Are Saying About Age Limits for Anti-Aging Skin Care

Anti-aging products are meant for people in their mid-to-late twenties and early thirties, not teenagers. However, many teens like to use these products because social media influencers promote them. Additionally, social media portrays aging skin as negative and unrealistic expectations of wrinkle-free skin. Thus, to fit in with this social media ideal, teens use these products to prevent wrinkles early.

Wardah, Valley Stream North

I think an age limit on anti-aging products is reasonable, seeing as so many young girls are being brainwashed by social media into thinking they need these products to be pretty. I’ve heard of girls younger than 15, even younger than 10, buying these anti-aging products — I think it’s silly because they’re still children, they’re not even adults yet and are worried about aging, but it’s not their fault. They’re given technology from a very young age that tells them they need to be flawless, smooth and glowing to be valued, which isn’t true. Of course, much more needs to be done to dismantle these beliefs, as it’s very typical of the beauty industry to push them to women, but marketing to under-18s is especially harmful. Having this kind of mentality since childhood is going to make it harder for these girls to free themselves from it.

Charlie, Minnesota

Physical appearance is definitely a big role in today’s society. At times I do feel pressured to look a certain way. When I used to do cheerleading, we had no choice but to put makeup all over our face and wear red lipstick because it made us “look better.” Instead of keeping the makeup minimalistic and more natural, they made it seem like they wanted us to hate our natural features.

Takya, NC

I think that this problem affects more girls than it does boys, as the culture around girls and looking their absolute best is not something that translates across the gender gap, as most boys are not too fussy over how their skin looks.

James, Franklin Square

Yes, girls, boys, and nonbinary students often face different pressures regarding their appearance due to societal expectations, media influence, and cultural norms. Girls are frequently pressured to conform to beauty standards that emphasize thinness, clear skin, and fashionable clothing, often reinforced by social media and advertising. Boys, on the other hand, may feel pressure to appear muscular, tall, or traditionally masculine, with fewer socially acceptable ways to express themselves through fashion or grooming. Nonbinary students can face unique challenges, as they may feel pressure to conform to either masculine or feminine standards or struggle with finding representation and acceptance of their authentic selves.

Dylan, New York

What’s Going On in This Graph? | March 26, 2025

0
What’s Going On in This Graph? | March 26, 2025

Note: We will host a live-moderated discussion of this graph on March 26. There will not be live moderation on March 19.


In 2018, Dr. Yinon M. Bar-On, a geophysicist, and his colleagues synthesized data from numerous sources plus some educated guesstimates to calculate the Earth’s mass of “living stuff” (biomass) and the earth’s mass of “man-made stuff” (technomass). In 2024, Brice Menard and Nikita Shtarkman visualized this research, as shown in the above three-dimensional bar chart, which displays the masses of seven main categories of living matter and six main categories of man-made matter. The animated version of this graph is available here.

The volumes of cubes are proportional to their total mass on Earth.

The research determined that there are 1.1 trillion tons of biomass and 1.3 trillion tons of technomass.

1. After looking closely at the graph above (or at this full-size image), answer these four questions:

  • What do you notice?

  • What do you wonder?

The questions are intended to build on one another, so try to answer them in order.

2. Next, join the conversation online by clicking on the comment button and posting in the box. (Teachers of students younger than 13 are welcome to post their students’ responses.)

3. Below the response box, there is an option to click on “Email me when my comment is published.” This sends the link to your response which you can share with your teacher.

4. After you have posted, read what others have said, then respond to someone else by posting a comment. Use the “Reply” button to address that student directly.

On Wednesday, March 26, teachers from our collaborator, the American Statistical Association, will facilitate this discussion from 9 a.m. to 2 p.m. Eastern time.

5. By Friday morning, March 28, we will reveal more information about the graph, including a free link to the article that includes this graph, at the bottom of this post. We encourage you to post additional comments based on the article, possibly using statistical terms defined in the Stat Nuggets.

We’ll post more information here by the morning of Friday, March 28. Stay tuned!


More?

See all graphs in this series or collections of 75 of our favorite graphs, 28 graphs that teach about inequality and 24 graphs about climate change.

View our archives that link to all past releases, organized by topic, graph type and Stat Nugget.

Learn more about the notice and wonder teaching strategy from this 5-minute video and how and why other teachers are using this strategy from our on-demand webinar.

Sign up for our free weekly Learning Network newsletter so you never miss a graph. Graphs are always released by the Friday before the Wednesday live moderation to give teachers time to plan ahead.

Go to the American Statistical Association K-12 website, which includes teacher statistics resources, Census in the Schools student-generated data, professional development opportunities, and more.

Students 13 and older in the United States and Britain, and 16 and older elsewhere, are invited to comment. All comments are moderated by the Learning Network staff, but please keep in mind that once your comment is accepted, it will be made public.

What’s Going On in This Picture? | March 17, 2025

0
What’s Going On in This Picture? | March 17, 2025

1. After looking closely at the image above (or at the full-size image), think about these three questions:

2. Next, join the conversation by clicking on the comment button and posting in the box that opens on the right. (Students 13 and older are invited to comment, although teachers of younger students are welcome to post what their students have to say.)

3. After you have posted, try reading back to see what others have said, then respond to someone else by posting another comment. Use the “Reply” button or the @ symbol to address that student directly.

Each Monday, our collaborator, Visual Thinking Strategies, will facilitate a discussion from 9 a.m. to 2 p.m. Eastern time by paraphrasing comments and linking to responses to help students’ understanding go deeper. You might use their responses as models for your own.

4. On Thursday afternoons, we will reveal at the bottom of this post more information about the photo. How does reading the caption and learning its back story help you see the image differently?

We’ll post more information here on Thursday afternoon. Stay tuned!


More?

See all images in this series or slide shows of 40 of our favorite images — or 40 more.

Learn more about this feature in this video, and discover how and why other teachers are using it in their classrooms in our on-demand webinar.

Find out how teachers can be trained in the Visual Thinking Strategies facilitation method.

Students 13 and older in the United States and Britain, and 16 and older elsewhere, are invited to comment. All comments are moderated by the Learning Network staff, but please keep in mind that once your comment is accepted, it will be made public.

Onboarding in Employee Development – Skills anyone?

0
Onboarding in Employee Development – Skills anyone?
  • Skill ratings can be a deceiver.
  • Likert Scale Skill Rating establish falsehoods, and when used with AI – tied as part of those skill ratings – the output is skewed
  • Skills tied to content for the opportunities angle only work if they truly reflect the person’s strengths, areas for improvement, and the manager’s perception, which may or may not be 100% accurate and, therefore, without validation.
  • Skill mapping is a benefit, yet many systems ignore it because the system does it for you rather than having you do it yourself—which is a long and awful process. It’s just like watching those DVD onboarding videos, especially the ones with the CEO welcoming you—hey, thanks. Is it too early to get a raise?
  • Skills taxonomies, skills this and that, skills assessments – the best in the business isn’t one you may have heard of – but you should
  • If just the word “upskilling” entices you, it’s because systems from day one were about identifying skill gaps and improving them—thus upskilling. Yep, back in 1999. Wow. Who knew?

The Impact of Confidence on Anxiety and Motivation

0
The Impact of Confidence on Anxiety and Motivation

Participants received feedback about their percentile after every task they did. After receiving all of the tasks, they were again assessed on their anxiety and motivation as well as their perception of their performance.

Results

Despite receiving varied feedback, there were no actual performance differences on any of the tasks. However, there were differences for perceived performance. Across all tasks, participants who received negative feedback thought they did much worse than those who received positive feedback. That’s probably not all that surprising. Being told you’re doing well makes you believe you’re doing well and vice versa. However, in addition to perceived performance, getting negative feedback also significantly increased anxiety, reduced intrinsic motivation, and increased amotivation compared to positive feedback . Those participants with higher anxiety had lower perceived performance as well.

Takeaway

These results indicate that your belief in your success on a task impacts your level of anxiety and motivation more so than your actual success! If you perceive yourself as doing poorly, it may cause you to pay more attention to your current state, feelings, and performance, and draw attention away from the task at hand.

In this study, that anxiety didn’t impact performance, but in real world situations it might. The stakes here involved maybe earning $5 for you and a peer… not terribly high stakes. But prior research has shown the impact of anxiety on performance when individuals are under pressure and there are some real world circumstances in which this might really matter.

One example that is relevant in my world is student performance on practice medical board exams. Students often want to know the median score for their class. They want to know how they are performing compared to their peers. As of right now, we do not disclose this information, stating that the purpose of these tests is to know whether you are on track to passing, not whether you are ahead of the game. These data make me even more confident in that decision. I don’t want to tell a student who is doing just fine that they are in the 30th percentile. That will increase their anxiety and reduce their motivation, which may lead to very real performance differences on the real exam, where the stakes are tremendously high.

As an educator, this indicates that student self-efficacy matters. Possibly more than their actual performance, students need to believe that they are capable and the way we provide feedback is a major contributor to that belief.

Watch: ‘Instruments of a Beating Heart’

0
Watch: ‘Instruments of a Beating Heart’

4. Next, join the conversation by clicking on the comment button and posting in the box that opens on the right. (Students 13 and older are invited to comment, although teachers of younger students are welcome to post what their students have to say.)

5. After you have posted, try reading back to see what others have said, then respond to someone else by posting another comment. Use the “Reply” button or the @ symbol to address that student directly.

6. To learn more, read “What a School Performance Shows Us About Japanese Education.” Ema Ryan Yamazaki, the filmmaker, writes:

What makes Japanese people distinctively Japanese? For me, the key lies in what we are taught during our elementary school years.

Children as young as 6 are given the responsibility to clean their own classrooms and serve one another lunch. Schools are structured like mini societies, where everyone has a role and is expected to contribute to the community. There’s a strong focus on nonacademic education intended to teach teamwork, work ethic and a sense of accomplishment.

Growing up in Japan as the child of a Japanese mother and a British father, I struggled with my identity. It was only years later when I was living abroad that I came to appreciate the values and work ethic instilled in me by my elementary school education; they are so normalized in Japan that their worth is underappreciated. These traits also contribute to why Japanese society works the way it does: Our trains run on time because we are taught to prioritize harmony and consideration for others; on the other hand, we live under a collective pressure to conform and not bring shame upon our community.

In the short documentary above, “Instruments of a Beating Heart,” filmed in 2022, first graders at a Tokyo public school are presented with a challenge for their final semester: to form an orchestra and perform at a school ceremony. As the children are taught to “make your hearts as one” and rigorously rehearse, we see both the pressures and the wonders of being held responsible to a group. The character-building traditions in Japanese education are experienced through Ayame, who, in the face of newfound challenges, learns to be resilient. I believe the experience of overcoming obstacles, as Ayame does, is crucial to education. But where should the balance lie between discipline and freedom?

What is happening in our schools will shape what our future society will look like. While the Japanese system has its strengths and weaknesses, I hope this film provides the opportunity for other societies around the world to hold a mirror to their educational systems and to reflect on how they want to raise the next generation.

7. Join us again on March 27 when we will be featuring The Daily episode “A Turning Point for Ultraprocessed Foods.”


Want more student-friendly videos and podcasts? Visit our Film and Podcast Club column.

Students 13 and older in the United States and Britain, and 16 and older elsewhere, are invited to comment. All comments are moderated by the Learning Network staff, but please keep in mind that once your comment is accepted, it will be made public.

Is There Too Much Cursing These Days?

0
Is There Too Much Cursing These Days?

How often do you hear curse words in the hallways at school? Hear them on TV and in movies? Read them in books or articles? Encounter them in music or on social media?

In your opinion, is there too much swearing today? Or is it simply part of the way we speak now?

In “Curses! A Swearing Expert Mulls the State of Profanity.” the Times reporter Matt Richtel invites Timothy Jay, a scholar in the science of swearing, to weigh in on those questions and more:

Cursing is coursing through society. Words once too blue to publicly utter have become increasingly commonplace. “Language is just part of the whole shift to a more casual lifestyle,” said Timothy Jay, a professor emeritus of psychology at the Massachusetts College of Liberal Arts in North Adams, Mass.

Dr. Jay has spent a career studying the use of profanity, from what motivates it to the ways in which it satisfies, signals meaning and offends. Although officially retired, he has continued to edit studies on profanity and he recently offered an expert opinion in an ongoing legal dispute in Michigan over whether the phrase “Let’s go Brandon” (a euphemism used to denigrate former President Joseph R. Biden Jr.) should be reasonably interpreted as “profane.” (It should not, Dr. Jay opined.)

Dr. Jay posits that the increasingly casual nature of the spoken word derives in part from the way people communicate on social media. One study, published in 2014 by other researchers in the field, found that curse words on Twitter, now known as X, appeared in 7.7 percent of posts, with profanity representing about 1 in every 10 words on the platform. That compared to a swearing rate of 0.5 to 0.7 percent in spoken language, the study found.

If that data troubles you, Dr. Jay has some thoughts on how to dial back the profanity.

Students, read the entire article and then tell us:

  • Are you noticing more — and perhaps stronger — foul language in places you didn’t used to see or hear it, as the article suggests? What is your reaction to this surge in obscenities?

  • Do you curse? If so, when and for what reasons do you do it? If not, why do you avoid it?

  • What is something you learned about swearing from Dr. Jay? Was there anything about its history, the reasons we use it or how we can change our habits around it that surprised you?

  • Can cursing become an issue? When do you believe it crosses a line, from being a harmless way to express oneself or blow off steam to being obnoxious, offensive or even dangerous?

  • Dr. Jay gives his theories for why he thinks cursing is increasing. What do you think might be driving our society’s more casual use of profanity? Is this a problem in your opinion? Why or why not?


Students 13 and older in the United States and Britain, and 16 and older elsewhere, are invited to comment. All comments are moderated by the Learning Network staff, but please keep in mind that once your comment is accepted, it will be made public and may appear in print.

Find more Student Opinion questions here. Teachers, check out this guide to learn how you can incorporate these prompts into your classroom.