IndiaBIX.com
Arithmetic Aptitude Data Interpretation
Logical Reasoning Verbal Reasoning Non Verbal Reasoning
General Knowledge
Sudoku Number puzzles Missing letters puzzles Logical puzzles Playing cards puzzles Clock puzzles
C Programming C# Programming Java Programming
Networking Database Questions Computer Science Basic Electronics Digital Electronics Electronic Devices Circuit Simulation Electrical Enigneering Engineering Mechanics Technical Drawing
Placement Papers Group Disucssion HR Interview Technical Interview Body Language
Aptitude Test Verbal Ability Test Verbal Reasoning Test Logical Reasoning Test C Programming Test Java Programming Test Data Interpretation Test General Knowledge Test
Data Structures Operating Systems Networking DATABASE Database Basics SQL Server Basics SQL Server Advanced SQL Server 2008 JAVA Core Java Java Basics Advanced Java UNIX Unix File Management Unix Memory Management Unix Process Managemnt C Interview Questions The C Language Basics .NET Interview Questions .NET Framework ADO.NET ASP.NET Software Testing

C Programming - Typedef - Discussion

@ : Home > C Programming > Typedef > General Questions - Discussion

Read more:

"Nothing is impossible to a willing heart."
- (Proverb)
1. 

In the following code, the P2 is Integer Pointer or Integer?

typedef int *ptr;
ptr p1, p2;

[A]. Integer[B]. Integer pointer
[C]. Error in declaration[D]. None of above

Answer: Option B

Explanation:

No answer description available for this question.


Kumaran said: (Sun, Nov 14, 2010 01:55:04 PM)    
 
Here we declared ptr as a pointer variable. Using that we can assign two pointers. First one hold the address of Ptr variable. And second one points the address of the first variable. Here the declaration is correct. And p1, p2 are not integers. So B is the answer.

Sunil said: (Sat, Dec 4, 2010 11:00:46 AM)    
 
Then whether p1 is an integer. Please answer any one with explanation.

Lordy said: (Sat, Dec 18, 2010 10:24:43 PM)    
 
@sunil

p1 is just a pointer. it is not declared as int so how can that be integer. think u will understand clearly.

Jigar said: (Fri, Jan 21, 2011 07:43:53 AM)    
 
@lordy

but ptr is integer type pointer so i think indirectly p1 is also integer

Vengatraman said: (Mon, Jan 24, 2011 12:47:49 AM)    
 
Becoz p1, p2 s assigned as ptr var & ptr is defined as integer. So I think as it is integer pointer.

Nishant said: (Mon, Mar 14, 2011 11:03:24 AM)    
 
ptr is the pointer which has the address at which value is stored.And p2 is defined as ptr so p2 is the integer pointer which has the address at which has integer value...

Raju said: (Wed, Jul 6, 2011 08:54:30 AM)    
 
Ptr is pointer to integer. Because p1 and p2 are declared as ptr and ptr is pointer to integer, p1 and p2 both will get the same functionality like integer pointer.

Teju said: (Sat, Aug 20, 2011 10:49:59 AM)    
 
The typedef allows the new name become equivalent to the type you wanted.

Thus, since prt is pointer to integer; p1 and p2 are integer pointers.

Eg:

typedef int arr[7][3];

/* Now declare some objects */

arr a; // Here a is 7*3 array of int.

Prasad said: (Fri, Sep 23, 2011 12:48:49 PM)    
 
*ptr is pointer varible, but when you assign p1 and p2 than p1 is hold the address of ptr but p2 is hold address of p1 ? please answer to me.

Parin said: (Fri, Dec 16, 2011 08:52:59 AM)    
 
Understand the question like this,
typedef (int *) ptr;
ptr p1,p2;

Now it is very clear that p1 and p2 are integer pointers..

Pankaj said: (Sun, Jan 1, 2012 02:47:21 PM)    
 
We defined value at ptr(*ptr) as integer. So p1 and p2 not storing the adress their is they are storing value.

#include<stdio.h>
int main()
{
typedef int *ptr;
ptr p1, p2;
printf("%d %d",p1,p2);
}

o/p: 0 0

Martin said: (Sun, Jan 15, 2012 01:42:05 AM)    
 
C is case sensitive and the question clearly asks what P2 is. There is no P2. There is a p2, but that is not the same. Therefore, the answer is D.

Write your comments here:
Name *:     Email:


© 2008-2011 by IndiaBIX™ Technologies. All Rights Reserved | Copyright | Terms of Use & Privacy Policy

Advertise     Contact us: info@indiabix.com     Follow us on twitter!