Write a program that inputs maximum 10 numbers but stops as soon as 4 even numbers are entered.
Answers
Answered by
6
Answer:
Explanation:
int arr[10],count=0;
for(int i=0;i<10;i++)
{
int num;
cout<<"enter a number";
cin>>num;
if(num%2==0)
count++;
if(count<4)
arr[i]=num;
else
break;
}
sswaraj04:
it's a general answer
Answered by
3
program in python:
for i in range ( 10 ):
num = int ( input ( "Enter a number : " ) )
if num == 4 : break
Explanation:
- first line of code says loop until the i value is less than 10
- default i value will be taken as 0 so the loop will iterate 10 times
- 2nd line input takes input from the user the int() method takes only the integer value, when you input a character or string it will show error
- 3rd line checks if the input num is equal to 4 or not, if true it breaks from the loop
- false the loop will again iterate by checking condition.
---Hope you understood my program. :)
Similar questions