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 C# Programming Java Programming
Microbiology Biochemistry Biotechnology Biochemical Engineering
Civil Engineering Mechanical Engineering Chemical Engineering 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 - Pointers - Discussion

@ : Home > C Programming > Pointers > Find Output of Program - Discussion

Read more:

"Nothing in life is to be feared, it is only to be understood."
- Marie Curie
15. 

What will be the output of the program ?

#include<stdio.h>

int main()
{
    printf("%c\n", 7["IndiaBIX"]);
    return 0;
}

[A]. Error: in printf[B]. Nothing will print
[C]. print "X" of IndiaBIX[D]. print "7"

Answer: Option A

Explanation:

No answer description available for this question.


Sathiya said: (Fri, Jun 18, 2010 08:38:32 PM)    
 
How does it takes 7th character("X") from IndiaBIX?

7["IndiaBIX"] shall we define like this?

Shamini said: (Mon, Aug 2, 2010 05:39:42 AM)    
 

printf("%c\n", 7["IndiaBIX"]);


It is printing the 7th character of the string "IndiaBIX".

I-0,
n-1,
d-2,
i-3,
a-4,
B-5,
I-6,
X-7.

Sathya said: (Mon, Aug 23, 2010 08:29:13 PM)    
 
Thanks Shamini.

Gopi said: (Thu, Dec 30, 2010 10:30:42 PM)    
 
Good. Thank you.

Narendra said: (Thu, Jan 20, 2011 11:27:49 PM)    
 
I think when we write like that then compiler will skip first 6 letters &then print remaining.

Umu said: (Sun, Feb 13, 2011 01:34:34 PM)    
 
@narender no you are wrong.

@samini good thnx. :).

Manoj said: (Wed, Feb 23, 2011 05:12:44 AM)    
 
Hey program is good, because whenever complier can't define any data type or user define %c means char or you can modify this program or define %f,
%d then you will get satisfied answer.

Wikiok said: (Thu, Mar 10, 2011 08:40:05 AM)    
 
myarray[5] == 5[myarray]

Arvind said: (Sat, Mar 26, 2011 02:51:15 PM)    
 
Thnx wikiok.

Rajutaya@Gmail.Com said: (Fri, Jul 22, 2011 03:19:06 PM)    
 
Ya correct guys, if it is printf("%d",7[indiabiA]);
means it will print the integer values as A=65

Venky said: (Sun, Aug 7, 2011 10:44:15 PM)    
 
Actually: num[i]<=>*(num+i)<=>*(i+num)<=>i[num]

So 7 is index and indiabix is string. Thus X of indiabix.

Raghu said: (Sat, Aug 13, 2011 02:51:02 PM)    
 
It is just trick of mathematics. a[3] = 3[a] --> they are commutative both are expanded by compiler as *(a+3) and *(3+a) respectively. Even you can assign a variable to 3[a] = "X" which is same as a[3]="X".

Sanketrjain said: (Sat, Aug 27, 2011 07:19:16 PM)    
 
Thanks raghu and shamini.

Lavanya said: (Mon, Sep 19, 2011 08:29:36 PM)    
 
Thanks venky, raghu and shamini.

Sindhu said: (Tue, Nov 29, 2011 12:59:06 PM)    
 
Thanks wikiok.

Mesv said: (Tue, May 29, 2012 08:13:42 PM)    
 
No need to think more.
7["givenstring"] means it take 7th char of that string.
And string starts from 0 index.
Here "r".

Devanshmody said: (Sun, Jul 1, 2012 11:32:33 AM)    
 
They have used %c so it will take one character and 7 is given and x is at 7 position.

Varun said: (Wed, Aug 22, 2012 08:09:07 PM)    
 
No it will not print all the characters after 6 characters. if we keep 7+"IndiaBIX" then we will get output as you told..@narendra

Harsha said: (Thu, Aug 23, 2012 01:21:43 AM)    
 
It will print all characters after x in the string since there is only one character left it prints x

Prasad said: (Wed, Sep 26, 2012 12:41:45 PM)    
 
Suppose take an example...


int a[3]={10,20,30};
printf("\n%d%d%d",0[a],1[a],2[a]);

same way as a[0] a[2]....
in the above example 7 is treated as index.

So it takes 7th character

Write your comments here:
Name *:     Email:


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

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