Curriculum
Course: C basic
Login

Curriculum

C basic

C Introduction

0/1

C Get Started

0/1

C Comments

0/1

C Constants

0/1

C Operators

0/1

C Break and Continue

0/1

C User Input

0/1

C Memory Address

0/1

C Structures

0/1
Text lesson

Real-Life Example

Real-Life Example

Here’s a practical example demonstrating the utilization of various data types to compute and display the total cost of a specified quantity of items:

Example

// Create variables of different data types
int items = 50;
float cost_per_item = 9.99;
float total_cost = items * cost_per_item;
char currency = ‘$’;

// Print variables
printf(“Number of items: %d\n”, items);
printf(“Cost per item: %.2f %c\n”, cost_per_item, currency);
printf(“Total cost = %.2f %c\n”, total_cost, currency);