Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Let's code a shopping cart program with C programming ๐Ÿ›’
Play lesson

C tutorial for beginners โš™๏ธ - Let's code a shopping cart program with C programming ๐Ÿ›’

4.0 (0)
13 learners

What you'll learn

This course includes

  • 6.5 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

#coding #programming #cprogramming This is a beginner's practice project to help you get accustomed to accepting user input in C. // SHOPPING CART PROGRAM char item[50] = ""; float price = 0.0f; int quantity = 0; char currency = '$'; float total = 0.0f; printf("What item would you like to buy?: "); fgets(item, sizeof(item), stdin); item[strlen(item) - 1] = '\0'; printf("What is the price for each?: "); scanf("%f", &price); printf("How many would you like?: "); scanf("%d", &quantity); total = price * quantity; printf("\nYou have bought %d %s/s\n", quantity, item); printf("The total is: %c%.2f", currency, total); return 0;

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere