save in Arrays

below code will show factorial results
as you can se do while command is using there
so i wanna save all the results which user will get in a single array and when user press "z" to exit then all the results should appear side by side
hope you understand waiting for answer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
printf("\tFactorial Generator");
do {
int a, b, c = 0;
printf("\n");
printf("\nEnter any number: "); scanf("%d",&a);
b = a;
for(int d=a;d>=1;d--)
{
 if(c==0) c=b;
 else c=c*b;
 b--;
 }
printf("\nThe Factorial of %d is %d",a,c); printf("\nPress any key to Continue\n");   }
while(getch()!='z');
{ printf("Press z again"); }
   getch();
   }
How about a vector of ints?
didn't got it bro
can you show me example
Probably use a map instead: http://www.cplusplus.com/reference/map/map/
bro can you just edit the above code please
1
2
3
4
std::map<int, int> Factoral;

Factoral[ a ] = c;
where to add this
Add it after you have calculated the values, which would be around line 18.
Topic archived. No new replies allowed.