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       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
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 ?    1 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 ?    2 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 ?    0 Yes 0 No
Poornima
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
Write a program that accepts a string where multiple spaces are given in between the words. Print the string ignoring the multiple spaces. Example: Input: “ We.....Are....Student “ Note: one .=1 Space Output: "We Are Student" IBM3
How would you print out the data in a binary tree, level by level, starting at the top?  3
Write an implementation of “float stringToFloat(char *str).” The code should be simple, and not require more than the basic operators (if, for, math operators, etc.). • Assumptions • Don’t worry about overflow or underflow • Stop at the 1st invalid character and return the number you have converted till then, if the 1st character is invalid return 0 • Don’t worry about exponential (e.g. 1e10), instead you should treat ‘e’ as an invalid character • Write it like real code, e.g. do error checking • Go though the string only once • Examples • “1.23” should return 1.23 • “1a” should return 1 • “a”should return 0 Qualcomm2
Write the program for displaying the ten most frequent words in a file such that your program should be efficient in all complexity measures. Google3
compute the nth mumber in the fibonacci sequence? TCS6
What do you mean by team??  2
What is external and internal variables What is dynamic memory allocation what is storage classes in C  2
Write a program to accept a character & display its corrosponding ASCII value & vice versa?  3
How can I return multiple values from a function?  3
how does the C compiler interpret the following two statements p=p+x; q=q+y; a.p=p+x; q=q+y b.p=p+xq=q+y c.p=p+xq; q=q+y d.p=p+x/q=q+y TCS2
how many header file is in C language ?  3
What are the uses of pre-processor directives?  2
why i join syntel? Syntel11
what is the use of getch() function in C program.. difference b/w getch() and getche()?? Wipro10
what is the difference between normal variables and pointer variables.............. Satyam4
what is the difference between <stdio.h> and "stdio.h" Kanbay5
how many argument we can pas in in a function CTS18
Given an array of length N containing integers between 1 and N, determine if it contains any duplicates.  2
how to do in place reversal of a linked list(singly or doubly)?  1
what is the difference between NULL & NUL keywords in C?  3
 
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