473,508 Members | 2,374 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to print largest even number in given string?

aveeva
33 New Member
String: NodeJs is one of the best technology

NodeJs 6

is 2

one 3

of 2

the 3

best 4

technology 10

From above, how to print technology which largest even number.

How to print the largest even number?
Jul 9 '19 #1
1 1090
dev7060
639 Recognized Expert Contributor
One algo could be:

- Store each word in an array and do condition checks. A word can be stored by pushing characters into an array until a space is found.

- Declare a var max and arr_max (an array) in the beginning (outside of loop body and everything) and set its size equal to the length of the first word and copy the word to arr_max intially. Then on each iteration, condition checks can be used like if the length is even and max < length, assign the value of new length to max and save the current word to arr_max.

- After the loop body, output max and arr_max.
Jul 9 '19 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
13975
by: zjut | last post by:
I need to implement the method : round(String name, int index) The given string maybe the every type of float type, ( the msdn given the regax is that : integral-digits]exponential-digits]) ...
6
22074
by: Andrew Poulos | last post by:
If I have a string with numerals in it and I want to get each number in sequence. Is there a way to do it without parsing the string character by character? For example, str =...
5
11023
by: John | last post by:
Which variable type (c#) can whole the largest whole number? I know this sounds silly but as double and decimal are made for numbers with decimals I am not sure. Also if anybody knows of any...
8
3695
by: cyberdwarf | last post by:
Hi I need to print a report which will always output an even number of pages (this is for duplex printing). ie, if the report ends with an odd number of pages, I need to output a blank sheet... ...
4
4206
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I am trying to convert the digits to even number so for example if I have 3 digit number, I want it to be 4 digit and If I have 5 digit number, I want it to be 6 digit. How can i...
1
1279
by: justB | last post by:
Hi I'm new to this. Could I get the C code to print the largest prime number of a number given by a user? I want to promt the user to input a valid number >0, and return its largest prime number. ...
16
3041
by: saki | last post by:
Write a program to print all the permutations of a given string.
2
3197
by: alemo91 | last post by:
Write a recursive function to print all possible permutations of a given string. For example if the input string is “abc” then the set of permutations is: abc, acb, bac, bca, cab, cba. Hint:...
2
1508
by: dasazzad | last post by:
Hello there, I was trying to print a simple number using this code: " print ("Test output %d" % 050) " but it is giving following output " Test output 40 "
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7120
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5050
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.