Thread: Multiplication of odd or even integers according to user selection.

1. Multiplication of odd or even integers according to user selection.

Greetings,

I've been fighting with this program for some hours now, and there are so many things the program is requesting that I'm overwhelmed, I was wondering if anybody can point me in the right direction.

I need a program that will calculate products based on user command (1 or 0), the user will select a number before this so that it can become the last number to be multiplied.

If user inputs 0, calculate: 1*3*5*…*n (n is an odd number picked by the user)

or 1*3*5*…*(n-1) (n is an even number picked by the user);

If user input 1, calculate: 2*4*6*…*(n-1) (n is an odd number picked by the user)
or 2*4*6*…*n (n is an even number picked by the user).

So far I got...

Code:
```#include<stdio.h>

int main()
{
int n;
int command;
int result;
int usernumber= 0;

printf("Please input a positive integer:");
scanf("%d", &n);

printf("Please input the command for computation of products:");
scanf("%d", &command );

If (command == 1, usernumber++){
do{
printf( "%d", result);
}
while( nums > n )
}

}```

2. You probably should be using a for loop. Note that keywords and names are case sensitive, so If and if are not the same.

3. Good observation, I didn't even notice hehe. Thanks for your help, I'll keep working on this monster.

4. If you are still having trouble after you put in a 'for' loop, post your new code.

Popular pages Recent additions