GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  TCS  >  C
Go To First  |  Previous Question  |  Next Question 
 C  |  Question 15 of 87    Print  
given the piece of code
int a[50];
int *pa;
pa=a;
to access the 6th element of the array which of the following is incorrect?
a.*(a+5)
b.a[5]
c.pa[5]
d.*(*pa + 5)
A



  
Total Answers and Comments: 2 Last Update: May 29, 2007   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
February 10, 2006 16:32:20   #1  
laxmikanth        

RE: given the piece of codeint a[50];int *pa;

correct ans is pa[5].

after executing the statement pa a;pa will point to the array a.now array a has 2 pointers which are a and other is pa.we can use subscript operator for pointers also when it points to an array.

so pa[5] will give 6th value in that array.


 
Is this answer useful? Yes | No
May 29, 2007 08:29:38   #2  
MA        

RE: given the piece of codeint a[50];int *pa;
You did not read the question correctly. Which option is WRONG.

And that is d) since you deference pa before the incrementation this is likely going to give you an invalid memory access

 
Is this answer useful? Yes | No

 Related Questions

Which of the following about the C comments is incorrect ?a.commentscan go over multiple linesb.comments can start any where in the linec.a line can contain comments with out any language statementsd.comments can occur within comments

Latest Answer : Here the statement if(x=6) is true because this is not a conditional operator it assigns 6 to x so it is true, the if condition is truethen y=7; ...

Read the folllowing code# define MAX 100# define MIN 100........if(x>MAX)x=1;else if(x

Given the piece of codeint a[50];int *pa;pa=a;to access the 6th element of the array which of the following is incorrect?a.*(a+5)b.a[5]c.pa[5]d.*(*pa + 5)

Regarding the scope of the varibles;identify the incorrect statement:a.automatic variables are automatically initialised to 0b.static variables are are automatically initialised to 0c.the address of a register variable is not accessiabled.static variables cannot be initialised with any expression

Latest Answer : I think value of y = 5.Because if you format the code, it will look like thisx = 10;y=5;if (x==10){}else if(x==9){}else{   y=8;}Since value of x is 10 so condition if (x==10) will satisfy. And there is no assignment for y. So value of y ...

What does the following code do?fn(int n,int p,int r){static int a=p;switch(n){case 4:a+=a*r;case 3:a+=a*r;case 2:a+=a*r;case 1:a+=a*r;}}a.computes simple interest for one yearb.computes amount on compound interest for 1 to 4 yearsc.computes simple interest for four year d.computes compound interst for 1 year

What is incorrect among teh followingA recursive functiiona.calls itselfb.is equivalent to a loopc.has a termination condd.does not have a return value at all

Latest Answer : the incorrect ans is if()then ie,option 3 bcos there is no then  keyword in c language ...

Consider the following C codemain(){int i=3,x;while(i>0){x=func(i);i--;}int func(int n){static sum=0;sum=sum+n;return(sum);}the final value of x isa.6b.8c.1d.3


 Sponsored Links

 
Related Articles

jQuery Table Row Finished Code

jQuery Table Row Finished Code The Finished Code Our second example page has demonstrated table row striping highlighting tooltips collapsing expanding and filtering Taken together the JavaScript code for this page is mosgoogle geshibot lang php" document ready function var highlighted
 

jQuery Interacting with Other Code

jQuery Interacting with Other Code We learned with our sorting and paging code that we can t treat the various features we write as islands The behaviors we build can interact in sometimes surprising ways; for this reason it is worth revisiting our earlier efforts to examine how they coexist with t
 

jQuery Completed sorting and paging code

Learning jQuery The Finished Code The completed sorting and paging code in its entirety follows mosgoogle geshibot lang php" fn alternateRowColors function tbody tr odd this removeClass even addClass odd ; tbody tr even this removeClass odd addClass even ; return this; ; document
 

N-Tier Architecture: Data Access Layer

N Tier Architecture Data Access Layer In an N Tier architecture the data access layer consists of components that aid one in the process of accessing the database When it is used correctly the data access layer serves as an abstract level for the structures of the database Simple changes that are ma
 

How to Access C++ Class Members

How to Access C Class Members In this C tutorial you will learn how to access Class members dot operator or class member access operator difference between struct and class and  scope resolution operator mosgoogle center It is possible to access the class members after a class is defined an
 

What are Data Access Tools

Data access is the process of entering a database to store or retrieve data. Data Access Tools are end user oriented tools that allow users to build structured query language (SQL) queries by pointing and clicking on the list of table and fields in the data warehouse. Thorough computing history, t
 

What is Data Element

In some aspects of information technology, a data element is referred to as any named unit of data which may or may not consist of other data items. In many electronic record keeping applications, a data element is a combination of bytes or characters which refer to a separate item of information li
 

What is Access Path

In relational database management system (RDBMS) terminology, Access Path refers to the path chosen by the system to retrieve data after a structured query language (SQL) request is executed. A query may request at least one variable to be filled up with one value or more. A query may look like th
 

What is Access Point

An access point (AP; or also "WAP" for "wireless access point") is a node responsible for the formation of a wireless network through connection between wireless communication devices. It acts as a central transmitter and receiver of wireless radio signals, and is
 

JavaScript Array Operations

JavaScript Array Operations In this JavaScript tutorial you will learn about different operations with array in JavaScript how to use the for in statement Combining Operations between arrays and within elements of an array joining two or more arrays and joining elements of an arrays along with synta
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape