1)what is the error in the following stmt where str is a
char array and the stmt is supposed to traverse through the
whole character string str?

for(i=0;str[i];i++)

a)There is no error.
b)There shud be no ; after the stmt.
c)The cond shud be str[i]!='\0'
d)The cond shud be str[i]!=NULL
e)i shud be initialized to 1

Answers were Sorted based on User's Feedback



1)what is the error in the following stmt where str is a char array and the stmt is supposed to tra..

Answer / rajesh

options A and C are correct....
Check it in C programming online editor www.codepad.org

Is This Answer Correct ?    4 Yes 0 No

1)what is the error in the following stmt where str is a char array and the stmt is supposed to tra..

Answer / niranjan kumar niraj

b)The cond shud be str[i]!='\0'

Is This Answer Correct ?    1 Yes 0 No

1)what is the error in the following stmt where str is a char array and the stmt is supposed to tra..

Answer / gayitri91

undoubtedly,the answer should be 'c'(the condition should be
str[i]!='\0'
correct syntax:
for(i=0;str[i]!='\0';i++)

Is This Answer Correct ?    2 Yes 2 No

1)what is the error in the following stmt where str is a char array and the stmt is supposed to tra..

Answer / vinod

Options D,E are correct for this

Is This Answer Correct ?    2 Yes 2 No

Post New Answer

More C Interview Questions

What is the difference between macros and inline functions?

5 Answers   Global Edge, L&T,


How to create struct variables?

0 Answers  


f=(x>y)?x:y a) f points to max of x and y b) f points to min of x and y c)error

4 Answers   HCL,


I need to take a sentence from input and sort the words alphabetically using the C programming language. Note: This is C not C++. qsort and strtok not allowed

4 Answers   Aspire,


How to write a code for random pick from 1-1000 numbers? The output should contain the 10 numbers from the range 1-1000 which should pick randomly, ie ,for each time we run the code we should get different outputs.

12 Answers   NetApp,






Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it?

3 Answers  


Array is an lvalue or not?

0 Answers  


Explain what is page thrashing?

0 Answers  


Can I initialize unions?

0 Answers  


Write a program that receives as input a number omaadel-n-print, four digits.

0 Answers  


for(i=0;i=printf("Hello");i++); printf("Hello"); how many times how will be printed?????????

8 Answers  


Explain output of printf("Hello World"-'A'+'B'); ?

0 Answers  


Categories