Freelancing(Developer & Trainer). Undertaking projects/assignments. Open for short & long term contracts.
⚡ C Programming 🔥 Ninja's Shopping #tecqmate
Get link
Facebook
X
Pinterest
Email
Other Apps
#include<stdio.h>
void main(){
int shops;
printf("How many shops will you be visiting? ");
fflush(stdin);
scanf("%d", &shops);
int inds, shop;
float cost, sum, min = 0.0f;
for(int i = 1, j; shops >= i; i++){
printf("You are at shop #%d. How many ingredients do you need at shop #%d? ", i, i);
scanf("%d", &inds);
sum = 0.0f;
for(j = 1; inds >= j; j ++){
printf("How much is ingredient #%d? ", j);
scanf("%f", &cost);
sum += cost;
}
if(1 == i || min > sum){
min = sum;
shop = i;
}
printf("Your total at shop #%d is $%.2f.\n", i, sum);
}
printf("Your cheapest order was at shop #%d and cost $%.2f.\n", shop, min);
}
Introduction: Understanding the fundamental concepts of PHP syntax and variables is essential for beginners. In this detailed blog post, we'll explore PHP syntax and variables in depth, providing you with clear explanations and practical examples to solidify your understanding. Table of Contents: 1. PHP Syntax Overview 2. Writing Your First PHP Script 3. Comments in PHP 4. PHP Variables 5. Variable Naming Conventions 6. Data Types in PHP 7. Assigning Values to Variables 8. Printing and Displaying Variables Let's dive into each section and explore PHP syntax and variables with detailed explanations and examples. 1. PHP Syntax Overview: PHP has a straightforward syntax. We'll cover the opening and closing PHP tags (`<?php` and `?>`), as well as basic structure and formatting guidelines for writing PHP code. 2. Writing Your First PHP Script: We'll walk you through writing your first PHP script step-by-step. You'll learn how to set up a development environment, ...
Comments
Post a Comment