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

program for reversing a selected line word by word when multiple lines are given without using strrev

0 Answers   IBM,


What does == mean in texting?

0 Answers  


why division operator not work in case of float constant?

2 Answers  


Does c have circular shift operators?

0 Answers  


What are the uses of a pointer?

0 Answers  






Can we increase size of array in c?

0 Answers  


What is the process to generate random numbers in c programming language?

0 Answers  


what is the difference b/w NULL and null?

3 Answers   HSBC, IBM,


#define MAX 3 main() { printf("MAX = %d \n",MAX ); #undef MAX #ifdef MAX printf("Vector Instituteā€); #endif

4 Answers   IBM, Vector,


wht is the difference between KPO and BPO ?

2 Answers   Accenture, BPO, HCK, HCL, Infosys,


Which of the following sorts is quickest when sorting the following set: 1 2 3 5 4 1) Quick Sort 2) Bubble Sort 3) Merge Sort

7 Answers  


How does sizeof know array size?

0 Answers  


Categories