Write a code for the length of string without using strlen() function.

AnswerBot
1y

Code to find length of string without using strlen() function.

  • Use a loop to iterate through each character of the string

  • Increment a counter variable for each character in the string

  • Stop the loop when ...read more

sinchana J
2y

#include<iostream>

using namespace std;

int main(){

char c[]="hello, how you doing'';

int i=0;

while(s[i]!='\0'){

i=i+1;

}

cout<<"length of the string is"<<i;

return 0;

}

PrepInsta
author
2y
I shared my screen and opened Jupyter notebook and started writing the code. #include int main() { char str[100]; int i, length=0; printf("Enter a string: \n"); scanf("%s",str); for(i=0;str[i[]!='\0';...read more
Add answer anonymously...
Accenture Associate Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter