0

hi guys,

i have some questions here

Q1- i want to write programme to count the even and oss numbers

example: the user input is 12345

so: even= 2 , odd = 3

this is my code

```
int even[5]={0,2,4,6,8};
int odd[5]={1,3,5,7,9};
int n[10];
int count_even = 0 ,count_odd = 0;
for(int j=0; j < 10; j++)
{
cin>>n[j];
for(int i=0; i < 5; i++)
{
if(n[j] == even[i]) count_even++;
if(n[j] == odd[i]) count_odd++;
}
}
cout << count_even << " " << count_odd;
```

can you show me what was my mistake?

****

Q2- i want to write a programme to ask the user to input the seconds, then convert it to hours,numutes,seconds

but i don't have an idea how to do it

can you show me the logic?

****

Q3- ask uesr to input a number then display this

example: input = 5

output: *****

****

***

**

*

this is my code

```
int n;
cin >> n;
for(int i = 0; i <= n; i++)
{
for(int j=0; i <=n; j++){
cout << "*";
n--;
}
}
```

****

Q4- ask user for ten numbers and then dsiplay the average

```
int numbers[10];
int sum = 0;
double average = 0;
cout << "Enter 10 numbers one by one: " << endl;
for(int i = 0; i > 10; i++){
cin >> numbers[i];
}
int i = 0;
while (i < 10)
{
sum += numbers[i];
i++;
}
// Calculate the average of the 10 numbers.
average = sum / 10.0;
cout << "The average is " << average << endl;
```

i really don't know what is the wrong in my code? especially the to get ten numbers

i can do it by using while loop but i want to use for loop

waitng for you