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   To Refer this Site to Your Friends   Click Here
Google
 
Categories >> Code-Snippets
 
 


 

Back to Questions Page
 
Question
what is the use of using for loop as "for(;;)"?
Rank Answer Posted By  
 Question Submitted By :: Jephin
I also faced this Question!!   © ALL Interview .com
Answer
Infinite loop
 
0
San
 
 
Answer
Evaluates the whole loop to be true infinite
 
0
Lalitha
 
 
Answer
for using first inisilization;second test counter;third 
increment/decrement
int i;
syntax: for(i=0;i<=100;i++)
 
0
Arun N Patil
 
 
 
Question
How we print the table of 3 using for loop in c 
programing?
Rank Answer Posted By  
 Question Submitted By :: Rajesh Verma
I also faced this Question!!   © ALL Interview .com
Answer
int i;
for(i=1;i<=10;i++)
{
      i=i*3;
      printf("%d",i);
}
 
0
Chitra
 
 
Answer
int i,no;
for(i=1;i<=10;i++)
{
      no=i*3;
      printf("%d",no);
}
 
0
Chitra
 
 
Answer
for(i=1;i<=10&&printf("3*%d=%d",i,3*i);i++);
 
0
Teja
 
 
Question
main()
      {	
      char a[4]="HELL";
      printf("%s",a);
      }
Rank Answer Posted By  
 Question Submitted By :: Susie
This Interview Question Asked @   Wipro
I also faced this Question!!   © ALL Interview .com
Answer
Answer :
HELL%@!~@!@???@~~!

      Explanation:
The character array has the memory just enough to hold the
string “HELL” and doesnt have enough space to store the
terminating null character. So it prints the HELL correctly
and continues to print garbage values till it 	accidentally
comes across a NULL character.
 
0
Susie
 
 
Question
char *someFun1()

		{

		char temp[ ] = “string";

		return temp;

		}

		char *someFun2()

		{

		char temp[ ] = {‘s’, ‘t’,’r’,’i’,’n’,’g’};

		return temp;

		}

		int main()

		{

		puts(someFun1());

		puts(someFun2());

		}
Rank Answer Posted By  
 Question Submitted By :: Susie
I also faced this Question!!   © ALL Interview .com
Answer
Answer : 

	Garbage values.

Explanation:

	Both the functions suffer from the problem of dangling
pointers. In someFun1() temp is a character array and so the
space for it is allocated in heap and is initialized with
character string “string”. This is created dynamically as
the function is called, so is also deleted dynamically on
exiting the function so the string data is not available in
the calling function main() leading to print some garbage
values. The function someFun2() also suffers from the same
problem but the problem can be easily identified in this case.
 
0
Susie
 
 
Question
char *someFun()

		{

		char *temp = “string constant";

		return temp;

		}

		int main()

		{

		puts(someFun());

		}
Rank Answer Posted By  
 Question Submitted By :: Susie
I also faced this Question!!   © ALL Interview .com
Answer
Answer : 

		string constant 

Explanation:

		The program suffers no problem and gives the output
correctly because the character constants are stored in
code/data area and not allocated in stack, so this doesn’t
lead to dangling pointers.
 
0
Susie
 
 
Question
Printf can be implemented by using  __________ list.
Rank Answer Posted By  
 Question Submitted By :: Susie
I also faced this Question!!   © ALL Interview .com
Answer
Answer :  

		Variable length argument lists
 
0
Susie
 
 
Question
main()

      { 

		int a=10,*j;

      	void *k; 

		j=k=&a;

        	j++;  

		k++;

        	printf("\n %u %u ",j,k);

      }
Rank Answer Posted By  
 Question Submitted By :: Susie
I also faced this Question!!   © ALL Interview .com
Answer
Answer :  

		Compiler error: Cannot increment a void pointer

      Explanation:

Void pointers are generic pointers and they can be used only
when the type is not known and as an intermediate address
storage type. No pointer arithmetic can be done on it and
you cannot apply indirection operator (*) on void pointers.
 
0
Susie
 
 
Question
main()

      {

      char a[4]="HELLO";

      printf("%s",a);

      }
Rank Answer Posted By  
 Question Submitted By :: Susie
I also faced this Question!!   © ALL Interview .com
Answer
Answer :  

		Compiler error: Too many initializers

      Explanation:

The array a is of size 4 but the string constant requires 6
bytes to get stored.
 
0
Susie
 
 
Question
Is this code legal?

      int *ptr; 

ptr = (int *) 0x400;
Rank Answer Posted By  
 Question Submitted By :: Susie
I also faced this Question!!   © ALL Interview .com
Answer
Answer :  

		Yes

      Explanation:

      The pointer ptr will point at the integer in the
memory location 0x400.
 
0
Susie
 
 
Question
void main()

      {

      char ch;

      for(ch=0;ch<=127;ch++)

      printf(“%c   %d \n“, ch, ch);

      }
Rank Answer Posted By  
 Question Submitted By :: Susie
I also faced this Question!!   © ALL Interview .com
Answer
Answer :  

      	Implementaion dependent

      Explanation:

The char type may be signed or unsigned by default. If it is
signed then ch++ is executed after ch reaches 127 and
rotates back to -128. Thus ch is always smaller than 127.
 
0
Susie
 
 
Question
void main()

      {

      int i=10, j=2;

      int *ip= &i, *jp = &j;

      int k = *ip/*jp;

      printf(“%d”,k);

      }
Rank Answer Posted By  
 Question Submitted By :: Susie
I also faced this Question!!   © ALL Interview .com
Answer
Answer :  

      Compiler Error: “Unexpected end of file in comment
started in line 5”.

      Explanation:

The programmer intended to divide two integers, but by the
“maximum munch” rule, the compiler treats the operator
sequence / and * as /* which happens to be the starting of
comment. To force what is intended by the programmer,

      int k = *ip/ *jp;	

      // give space explicity separating / and * 

      //or

      int k = *ip/(*jp);

      // put braces to force the intention  

      will solve the problem.
 
0
Susie
 
 
 
Back to Questions Page
 
 
 
 
 
   
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