You are on page 1of 2

/* While purchasing a certain items, a discount of

10% is offered if the quantity purchased is more


than 1000.*/
/* The quantity and price per items are input
through the keyboard. */
/* Write a program to calculate the total expenses*/

#include<stdio.h>

int main()
{
//declare variables
int quantity;
float price;
float totalExpenses;
int discount = 10; // initialize variables

//prompt user for input


printf("Enter the quantity purchased: ");
//read and store input in quantity
scanf("%d", &quantity);

//prompt user for input


printf("Enter the price per item: ");
//read and store input in price
scanf("%f", &price);

//check the conditions


if(quantity > 1000)
{
//if the condition is true execute the following
totalExpenses = quantity * price;
totalExpenses = totalExpenses - (totalExpenses * 10/100);
}
else
{
//if the condition is false execute the following
totalExpenses = quantity * price;
}

//print the result


printf("Total Expenses: %.2f\n", totalExpenses);
return 0;
}
/* Make a program that prints out the first 8
multiples of a given integer */
// Use for-loop

#include <stdio.h>

int main()
{

int y;
int i;

//prompt user for input


printf("Enter a number: ");
//read and store input in y
scanf("%d", &y);

for ( i=1; i<=8; i++)

//i is initializes as 1
// i <= 8 (test expression)
//i++ (increment)

//print the result


printf(" %d ", i*y);

return 0;
}

You might also like