0
basic C study and I’m having problems with logic, I’m doing some exercises that require calculations like factoring decomposition and even problems like "A is twice the age of B when A was the age of B, if we add the age of A and B today we would have 81 years" I can’t put the calculations in the program what I can do, what I can study.
example this exercise is factoring:
#include <stdio.h>
#include <stdlib.h>
/*fazer um programa para deconpor um numero por numeros primos*/
int main()
{
int num,primo,i,cont=0, deco, aux=0;
printf("digite um numero para ele ser doconposto:\n");
scanf("%i", &num);
printf("digite um numero primo:\n");
scanf("%i", &primo);
for(i=1;i<=primo;i++)
{
aux=primo%i;
if(aux==0)
cont++;
if(cont==2)
{
deco=num%primo;
printf("%i", deco);
}
else if(cont!=2)
{
printf("nao eh um numero primo digite outro numero:\n");
scanf("%i", &primo);
}
if(deco!=1)
{
printf("digite outro numero:\n");
scanf("%i", &primo);
}
if(deco==1)
break;
}
return 0;
}
The difficulty is in making the code?
– anderson seibert
yes the difficulty is in making the code
– Leonardo V. De Gasperin
Already started something? you want to do this age problem in code?
– anderson seibert
Hello. It is not very clear what you are asking. Have you come to try something for one of the problems you mention? If yes, you could include your code in the question. It makes it easier for the community to help you.
– Luiz Vieira
Ready Lead I put an example
– Leonardo V. De Gasperin
You know how to solve the problem mathematically?
– Beterraba
yes I know, I already resolsovi with a pseudocode but still I cannot make the conversion to the program
– Leonardo V. De Gasperin
Look guys I just need to know how to pass something from the paper to the IDE and work I need a study material is what I need, if someone knows to indicate I will be grateful
– Leonardo V. De Gasperin
If what you need is study material, take a look here, and especially at the end of our wiki tag of C. The format of questions and answers of this site does not work well for recommendations of this kind, and so I will close the question ok?
– bfavaretto