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
void main()
{
int s[4][2]={ {1234,56},{1212,33},{1434,80},{1312,78} };
int (*p)[2];
int i,j,*pint;
for(i=0;i<=3;i++)
{
p=&s[i];
pint=p;
printf("\n");
for(j=0;j<=1;j++)
printf("%d",*(pint+j));
}
} while running this program it shows a warning-suspicious
pointer conversion ie pint=p; my que is why should we assign
the value of p to pint again.why cant we use it directly as
*(p+j)..but if i use like tat the o/p is garbage value..
 Question Submitted By :: Agita
I also faced this Question!!     Rank Answer Posted By  
 
  Re: void main() { int s[4][2]={ {1234,56},{1212,33},{1434,80},{1312,78} }; int (*p)[2]; int i,j,*pint; for(i=0;i<=3;i++) { p=&s[i]; pint=p; printf("\n"); for(j=0;j<=1;j++) printf("%d",*(pint+j)); } } while running this program it shows a warning-suspicious pointer conversion ie pint=p; my que is why should we assign the value of p to pint again.why cant we use it directly as *(p+j)..but if i use like tat the o/p is garbage value..
Answer
# 1
p ia pointer to an array when p is incremented it will increment by the number of elements in the array...
for example 
 int (*p)[2]; //it is aponiter to an arry of 2 elements so when we do p+1 then it will be incremented by two*(sizeof(int)) 
so leading to the garbage value at the last loop..

can be properly analyzed by the below program 

#include<stdio.h>


main()
{
int s[4][2]={ {1234,56},{1212,33},{1434,80},{1312,78} };
int (*p)[2];
int i,j,*pint;
for(i=0;i<=3;i++)
{
p=&s[i];
//pint=p;
printf("\n");
for(j=0;j<=1;j++)
printf("%p.....%d\n",*(p+j),**(p+j));
}
}
 
Is This Answer Correct ?    1 Yes 0 No
Test
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
Why the use of alloca() is discouraged? Oracle2
what is the difference between malloc() and calloc() function?  1
Reverse the part of the number which is present from position i to j. Print the new number. eg: num=789876 i=2 j=5 778986  1
how to make program without <> in library. ADITI1
Write a program to accept a character & display its corrosponding ASCII value & vice versa?  4
If 4 digits number is input through the keyboard, Write a program to calculate sum of its 1st & 4th digit.  4
what is the output of below pgm? void main() { int i=0; if(i) printf("pass"); else printf("fail"); }  3
write a addition of two no. program with out using printf,scanf,puts .  3
if a person is buying coconuts of Rs10,and then sell that coconuts of Rs9,with the loss of one rupee.After that the person became a millaniore.how? Wipro5
main() {int a=200*200/100; printf("%d",a); } TCS7
4.weight conversion: Write a program that will read weight in pounds and convert it into grams.print both the original weight and the converted value.There are 454 grams in a pound.design and carry out a test plan for this program. Wipro1
How to write a program for swapping two strings without using 3rd variable and without using string functions. iGate5
i want the code for printing the output as follows 4 4 3 3 2 2 1 1 0 1 1 2 2 3 3 4 4  1
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
wats SIZE_T meant for?  1
What character terminates all strings composed of character arrays? 1) 0 2) . 3) END  3
plz answer....A program that takes 3 variables e.g a,b,c in as seperate parameters and rotates the values stored so that value goes a to b, b to c and c to a .  3
how to find the kth smallest element in the given list of array elemnts. Silicon5
what is a c-language.what is do. HCL3
what are the uses of structure? HCL5
 
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