Operators
Candy Distribution
Calculate how many candies each friend gets and how many are left over.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Calculate how many candies each friend gets and how many are left over.
| Input | Candies: 25, Friends: 4 |
| Expected Output | Each friend gets 6 candies, Leftover candies: 1 |
#include <stdio.h>
int main() {
int candy, friends;
int leftover, got;
printf("Enter the no of candies: ");
scanf("%d", &candy);
printf("Enter no of friends: ");
scanf("%d", &friends);
got = candy / friends;
leftover = candy % friends;
printf("Each friend will get %d candies\n", got);
printf("leftover candies = %d", leftover);
return 0;
}
Enter the no of candies: 25
Enter no of friends: 4
Each friend will get 6 candies
leftover candies = 1