Dorsa R.

asked • 08/25/20

c programming :

i have written this program in C to get " n" (number ) first and then get "n "strings , compare the length of all strings and print the biggest one but the program wont compile please help :


#include <stdio.h>

#include <stdlib.h>

#include <string.h>


int main()

{

int n , i;

int max , maxlen;

scanf("%d",&n);

char a[100];

for (int i =1 ; i <= n ; i++)

{


scanf("%s",a);

}

max = 0;

maxlen = strlen(a[0]);


for (int i =1 ; i <= n ; i++);

{

if (strlen(a[i]) > maxlen);

{

maxlen = strlen(a[i]);

max = i;

}

}

printf("The longest is: %s with length equal: %d\n", a[max], maxlen);



return 0;

}



1 Expert Answer

By:

Patrick B. answered • 08/26/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.