Mastery 6

--Originally published at Programing 101

The difficult part : i forgot everything about factorial numbers so a found a video in youtube explaining what was that and then check it in the cplusplus page about factorial, i found it and i did my own, obviously my firs try didn’t work but it was because i didn’t declare my variables

 the easy part : checking the programing of my friends and ones in the internet

what i learn:

  • how to do a factorial again
  • how to put that factorial to work in my program

661

>>c++ page command<<<

>>Factorial numbers<<


wsq6

--Originally published at Salva blog

With this homework I got a lot of trouble because one of the topics for making this program was difficult for me a lot of people was trying this code in various ways so I try the one one of my friends told me to see.

https://talkingchalkpassingby.wordpress.com/

his blog post was good and I really could understand what the code was explaining to me in a way I could use it in the computer so I used this code as a reference for mine.

2017-03-30 (2)


#WSQ6 factorial calculator

--Originally published at My lonely happy place

i was writing this blog a couple of days before, but i was in a rush and run out of time without finish it and don’t  really remember what i wanted to say about it, so i’ll reserve myself to put some pictures with maybe a simple explanation, some pics and the code Captura de pantalla (188)Captura de pantalla (189)

what i have done is jut make a function that calculates the factorial of a number and call it inside my main, this function need 1 income of data from the user to use it as a limit and know how far should it have to keep working, and then take two variables with value one and make a product betwen ponints, then one of those values take the value of the result and ads one to the another, and repeats the loop over and over and over again until the summed number reaches the limit number, and then return the multiplied number,  but it don’t take much time to realise that my program don’t work above fifteen, witch i think happens due to my program have to do a way to long process to keep running above that, and just returns a negative value.

as usual, some shots of how it works.

Captura de pantalla (191)

and also as usual here is write code because i know nobody is going to use it, but it’s a requirement of the task.

 

#include<iostream>
using namespace std;

int factorial(int factor)
{
int proceso=1;
int resultado=1;
while(proceso<=factor)
{
resultado=resultado*proceso;
proceso=proceso+1;
}
return resultado;
}

int main()
{
int primnum;
int secnum;
cout<<“please give me a number an i will give you the factorial of that number.”<<‘\n’;
cin>>primnum;
int primopera=factorial(primnum);
cout<<“the factorial of your number is:”<<primopera<<‘\n’;
char chose;
cout<<“if you want the factorial of another number please type y, if you dont please

Continue reading "#WSQ6 factorial calculator"