main()

{

register int a=2;

printf("Address of a = %d",&a);

printf("Value of a = %d",a);

}

Answers were Sorted based on User's Feedback



main() { register int a=2; printf("Address of a = %d",&a); ..

Answer / susie

Answer :

Compier Error: '&' on register variable

Rule to Remember:

& (address of ) operator cannot be applied on register
variables.

Is This Answer Correct ?    3 Yes 1 No

main() { register int a=2; printf("Address of a = %d",&a); ..

Answer / chandra

It all depends on C/C++.

On C(GNU C/Visual studio C compiler), it will get a compiler
error.
since the keyword with register is stored in registers of
CPU rather than in memory locations of RAM.

On C++(GNU C++/Visual stdio C++ compiler), variable 'a' will
get an address of memory locations.
since register will automatically take address of memory

Is This Answer Correct ?    1 Yes 0 No

main() { register int a=2; printf("Address of a = %d",&a); ..

Answer / shrikantauti

Will produce an error as the memory address s not provided.
%u should had written instead of %d

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More C Code Interview Questions

main() { int i, j, *p; i = 25; j = 100; p = &i; // Address of i is assigned to pointer p printf("%f", i/(*p) ); // i is divided by pointer p } a. Runtime error. b. 1.00000 c. Compile error d. 0.00000

3 Answers   HCL,


#include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s=malloc(sizeof(struct xx)); printf("%d",s->x); printf("%s",s->name); }

1 Answers   TCS,


#include<stdio.h> main() { register i=5; char j[]= "hello"; printf("%s %d",j,i); }

2 Answers  


main() { int *j; { int i=10; j=&i; } printf("%d",*j); }

9 Answers   HCL, Wipro,


write a c program to Reverse a given string using string function and also without string function

1 Answers  


WAP to display 1,2,3,4,5........N

2 Answers  


given integer number,write a program that displays the number as follows: First line :all digits second line : all except the first digit . . . . Last line : the last digit

8 Answers  


Write a complete program that consists of a function that can receive two numbers from a user (M and N) as a parameter. Then print all the numbers between the two numbers including the number itself. If the value of M is smaller than N, print the numbers in ascending flow. If the value of M is bigger than N, print the numbers in descending flow. may i know how the coding look like?

2 Answers  


hello sir,is there any function in C that can calculate number of digits in an int type variable,suppose:int a=123; 3 digits in a.what ll b answer?

6 Answers  


Develop a routine to reflect an object about an arbitrarily selected plane

0 Answers  


Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all.

2 Answers   Mentor Graphics, Microsoft,


main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }

9 Answers   CSC, GoDB Tech, IBM,


Categories