473,383 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

What is the output of following code?

#define EXMP 25
main ( )
{ int exmp = 35;
printf (“\nvalue of exmp is %d”,EXMP);
}

my answer is 35
Is it correct?
Aug 10 '10 #1

✓ answered by Oralloy

Not only are identifiers case sensitive, but keywords are as well.

In this case, you also have a macro, which modifies the source code before the compiler even gets ahold of it. Your code after preprocessing is equivalent to:
Expand|Select|Wrap|Line Numbers
  1.  
  2. main ( )
  3. { int exmp = 35;
  4. printf (“\nvalue of exmp is %d”,25);
  5. }
Observe that the definition is erased and the token EXMP is replaced with the value from the definition.

Hopefully that helps a little.

Cheers!

5 1696
Oralloy
987 Expert 512MB
Why do you think 35 is the correct answer?
Aug 10 '10 #2
In C the IDENTIFIERS are case sensitive. Hence I think the same applies here? Is it ok
Aug 10 '10 #3
Oralloy
987 Expert 512MB
Not only are identifiers case sensitive, but keywords are as well.

In this case, you also have a macro, which modifies the source code before the compiler even gets ahold of it. Your code after preprocessing is equivalent to:
Expand|Select|Wrap|Line Numbers
  1.  
  2. main ( )
  3. { int exmp = 35;
  4. printf (“\nvalue of exmp is %d”,25);
  5. }
Observe that the definition is erased and the token EXMP is replaced with the value from the definition.

Hopefully that helps a little.

Cheers!
Aug 10 '10 #4
yes u r correct

Thanks Oralloy...
Aug 10 '10 #5
Oralloy
987 Expert 512MB
You're welcome, vensriram.

Cheers!
Aug 10 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: srikanth | last post by:
static char buf = {1,2,3,4,5,6,7,8}; printf("Address: %u : Val = %d \n",(int*)buf+1,*((int*)buf+1)); Thanks Vija
1
by: Marlon | last post by:
<! -- Web.config--> <authentication mode="Windows" /> <identity impersonate="true" /> <! -- Web.config--> where Configurations.ADsUsersPath is...
3
by: Razvan | last post by:
Hi! What is wrong with the following code ? // Test1.cpp : Defines the entry point for the console application. //
4
by: -D- | last post by:
I'm new to .net and just learning c#. I have the following code in vb and want to convert this to c# Public Class PositionData Private strText As String Private strUrl As String Public...
7
by: Jason Kid | last post by:
Hi, Please tell me what's wrong with the following code. private bool CheckIt( int iArg, bool fArg) { bool fIsGood = false;
1
by: aboood | last post by:
Hi guys Could any one tell me what does that code do please? in pseudo-code #include <fstream.h> #include <iostream.h> bool differsByOneDigit ( int , int ); void outputResults ( ofstream & ,...
2
by: SRT | last post by:
Hi, I have the following code below, which works if I do the following Call No1 'Call No2 Exit Sub For whatever reason it fails at Me!.SetFocus at the end of Sub No2 with
3
by: himanigarg | last post by:
what is the output of the following code: main() { char p="%d\n"; p='c'; printf(p,65); } i need the explanation of the output.
6
by: CSharper | last post by:
I have following code, if you cut and paste it in VS and compile it you see only an answer of 0. I was expecting values from o through 2999 using System; using System.Collections.Generic;...
5
by: naeemzi | last post by:
plz sir, solve me the following problum. #include <iostream.h> #include <windows.h> char customer_name; char description; void output(char customer_name, char movie_name, char nights,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.