Can someone help me and solve this question?! I will be great full... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can someone help me and solve this question?! I will be great full...

Write a program that will count even numbers from N integers entered by user. For instance: if user entered 10, 45, 1, 55, 3, 4, 7. Then the output must be 2

16th Mar 2022, 5:56 AM
Kazy
Kazy - avatar
28 Answers
+ 4
😁You will be great full of what? proud?, beer?, gratitude? I can solve it. But I won't. Do your homework by your own.
16th Mar 2022, 6:42 AM
Shadoff
Shadoff - avatar
+ 4
Kazy Show your trial code first so that the others can help. Thank you!
16th Mar 2022, 7:29 AM
Adil
Adil - avatar
+ 4
Manav Roy[LESS ACTIVE DUE TO EXAMS] ,devanille mohammed shibli, elraptor507 gojand507 , thank you guys i code it like this thanks for your help.. 💜 The Code: https://code.sololearn.com/cLw4qf36VEWn/?ref=app
20th Mar 2022, 7:35 PM
Kazy
Kazy - avatar
+ 3
We didn't help because you didn't code anything. Show us your ideas/logic and maybe we can help you to get started.
16th Mar 2022, 9:01 AM
HungryTradie
HungryTradie - avatar
+ 3
Manav Roy sorry i saw ur comment now, Ok iam gonna try to do it and tell u later, and sorry i took your time alot 🙏🏻
18th Mar 2022, 8:57 AM
Kazy
Kazy - avatar
+ 2
Manav Roy basically this code is more problem solving oriented. For ease I have added comments in sum. Actual code is this #include <stdio.h> int main() { int N; scanf("%d",&N); int a[N]; for( int i=0;i<N;i++) { scanf ("\n%d",&a[i]); } int s=0; for( int j=0;j<N;j++) { if(a[j]%2==0) { s+=a[j]; } else continue ; } printf ("%d",s); return 0; }
17th Mar 2022, 4:08 PM
Md Saif Ali
Md Saif Ali - avatar
+ 2
Hi kazy, Do you want to print EVEN INTEGERS OR 2?
17th Mar 2022, 10:29 PM
Haris
+ 2
mohammed shibli Iam a beginner with C# too idk too much about it.
18th Mar 2022, 8:47 AM
Kazy
Kazy - avatar
+ 1
Ok, i think i need nasted for to solve the problem and inside for we must put nasted if. that's my opinion so idk. What do you think?
16th Mar 2022, 10:23 AM
Kazy
Kazy - avatar
+ 1
Do you know how to copy+paste your code into a SoloLearn "code bit"? Create a new code bit by clicking/tapping the "code" tab, then + and select the language. Paste your code, save it, then attach it to your original post here by editing the post and using the plus icon. I don't understand your words, but I will know your code ✅
16th Mar 2022, 10:33 AM
HungryTradie
HungryTradie - avatar
+ 1
Try It first and put your Code later. A tip: to know if a number is even or pair, you have to divide by 2
16th Mar 2022, 4:46 PM
Mojo
+ 1
If(n%2==0)
17th Mar 2022, 12:34 AM
Jackie
Jackie - avatar
+ 1
Manav Roy thanks brother iam gonna try it.
17th Mar 2022, 12:40 PM
Kazy
Kazy - avatar
+ 1
devanille thanks for your explanation, i appreciate it.
17th Mar 2022, 2:46 PM
Kazy
Kazy - avatar
+ 1
#include <stdio.h> int main() { int N; scanf("%d",&N); int a[N]; for( int i=0;i<N;i++) { scanf ("\n%d",&a[i]); } int s=0,c; for( int j=0;j<N;j++) { if(a[j]%2==0) { s+=a[j]; c++; } else continue ; } printf ("Sum :%d",s); printf("total even : %d",c); return 0; }
17th Mar 2022, 3:27 PM
Md Saif Ali
Md Saif Ali - avatar
+ 1
Manav Roy actually this program is a solution of challenge programs of Sololearn,but it has a little variation. So , i forget to remove sum
17th Mar 2022, 3:55 PM
Md Saif Ali
Md Saif Ali - avatar
+ 1
Add if and ifelse and use intervalle that what I can say
17th Mar 2022, 5:21 PM
Zineb Nafil
+ 1
Md Saif ali Thanks for your hard work but i need C# code i don't get this.
17th Mar 2022, 5:34 PM
Kazy
Kazy - avatar
+ 1
Kazy oh sry! I don't have it.
17th Mar 2022, 5:36 PM
Md Saif Ali
Md Saif Ali - avatar
+ 1
first you have to save all the numbers of the input in a list , with the split function using "," as separator and other text tricks for blank spaces in the input you will solve it. after this you can use a for loop iterating in our list to count which numbers are even. Then print the count Variable. My documented code with this steps https://code.sololearn.com/cNJBEfwrzU3u/?ref=app as my answer contain the full explanation i can include my short oneline code: (run in python) https://code.sololearn.com/cu9dKjJ5NWWv/?ref=app
17th Mar 2022, 8:32 PM
elraptor507 gojand507
elraptor507 gojand507 - avatar