Need some help with my program please.
Our professor gave us an assignment but I'm having some trouble with it:
ASSIGNMENT 3
We can define a triple as a sequence of three non-negative numbers. Here are some examples of triples:
8 2 4 6 0 9 9 0 6 12 7 7 3 38 10
Write a program that prompts the user for an integer, then prints all possible triples that add up to that number and a count of how many triples there are.
For example, if the user enters 3, the program prints
0 0 3
0 1 2
0 2 1
0 3 0
1 0 2
1 1 1
1 2 0
2 0 1
2 1 0
3 0 0
count: 10
Hint: use three nested loops.
Here's what I have so far:
Code:
#include <stdio.h>
int main() {
int i,j,num;
printf("Enter a number: ");
scanf("%d", &num);
for(i=0; i<num; i++) {
for (j=0; j<num; j++)
printf("%d %d %d\n", i, j, num);
}
return 0;
}
:confused: * I'm stuck at this point because I can't figure out how to make it so that when a user is asked to enter an integer, the program can print out possible integers to add up to that number & keep count. Any advice that anybody can give is greatly appreciated.*
Thank You So Much! :)