top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How can I print the longest number in a string?

+2 votes
55 views

How can I print the longest number in a string?

posted Apr 30, 2014 by Muskan

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

+1 vote
size_t maxlen = 0, len;
int i, maxindex = 0;

for (i = 1; i < argc; i++) {
    len = strlen(argv[i]);
    if (len > maxlen) {
        maxlen = len;
        maxindex = i;
    }
}

printf("The longest string is '%s'\n", argv[maxindex]);
answer Dec 1, 2014 by Shivaranjini
Similar Questions
+3 votes

I hope behavior would be same across languages?

+2 votes

How do I make a checkbox required on an ASP.NET form?

+2 votes

How to use String .Format for an email id?

0 votes

Given a string S and set of strings U. Find the length of longest prefix of S that can be formed using strings in U.

For example you have following -

S= “absolute”
U={“abs”,”xyz”,”ol”,”te”}

Answer: 5 i.e "absol"

Now the task is to have the algorithm/program for the above problem, please help me with this?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...