ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
how to generate the length of a string without using len 
funtion?
 Question Submitted By :: Shephaliaishwarya
I also faced this Question!!     Rank Answer Posted By  
 
  Re: how to generate the length of a string without using len funtion?
Answer
# 1
int strlength(char s[])
{
  int i,len;
  for(i=0;s[i];i++)
      len++;
   return len;
}
 
Is This Answer Correct ?    2 Yes 2 No
Shreesha Vailaya
 
  Re: how to generate the length of a string without using len funtion?
Answer
# 2
** same as above.. only u should initialise the valued of 
varibale len to 0..
otherwise it will pick up some garbage value.. **


int strlength(char s[])
{
  int i , len;
  
  len = 0;
  for(i = 0 ; s[i] != '/0' ; i++)
  {
    len++;
  }

return len;
}
 
Is This Answer Correct ?    5 Yes 0 No
Shruti
 
 
 
  Re: how to generate the length of a string without using len funtion?
Answer
# 3
#include<stdio.h>
int strlength(char *);
int main()
{
  char *str;
  int len;
  printf("Enter a string : ");
  gets(str);
  len=strlength(str);
  printf("Length of %s is %d",str,len);
  return 0;
}
int strlength(char *str)
{
  int len=0;
  for(;*str!='\0';str++)
  {
    len++;
  }
  return len;
}
 
Is This Answer Correct ?    1 Yes 0 No
Poornima
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
declare afunction pointer to int printf(char *)? HCL1
Switch (i) i=1; case 1 i++; case 2 ++i; break; case 3 --i; Output of i after executing the program Mascot4
When is an interface "good"?  1
In the following code segment what will be the result of the function, value of x , value of y { unsigned int x=-1; int y; y = ~0; if(x == y) printf("same"); else printf("not same"); } a) same, MAXINT, -1 b) not same, MAXINT, -MAXINT c) same , MAXUNIT, -1 d) same, MAXUNIT, MAXUNIT e) not same, MAXINT, MAXUNIT IBM1
What are advantages and disadvantages of recursive calling ? HP11
why i join syntel? Syntel12
can anyone proide me reading material on svit00ef27@yahoo.com please thanx in advance IBM1
What is RAM memory? and What is ROM?Who designed one is temparary and another is permanent?why they designed like that?By using far pointer which type data(whether hexadecimal)we can access? Excel1
What is the memory allocated by the following definition ? int (*x)[10]; ADITI3
what is the advantage of software development  1
How can I allocate arrays or structures bigger than 64K?  4
What is the relation between # and include<stdio.h> HCL3
HOW TO ANSWER IF ASKED " WHAT KIND OF A PERSON ARE YOU?" I NEED AN ANSWER THAT IMPRESS THE INTERVIEWER  2
4.A function 'q' that accepts a pointer to a character as argument and returns a pointer to an array of integer can be declared as: A)int (*q(char*)) [] B)int *q(char*) [] C)int(*q)(char*) [] D)None of the Above Accenture4
write a program to generate 1st n fibonacci prime number  1
What is the meaning When we write "#include" what is # and what does include does there??? HCL11
write a function for strtok()?? Verifone1
how to find out the biggest element (or any other operation) in an array which is dynamic. User need not to mention the array size while executing.  2
write a c programs to do multiplication of two numbers with out using arithmatic operator ?????????? TCS4
which will be first in c compiling ,linking or compiling ,debugging. Sonata3
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com