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 - Const - Discussion

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

Read more:

"Time and tide wait for none."
- Alexander Pope
10. 

What will be the output of the program?

#include<stdio.h>

int main()
{
    const c = -11;
    const int d = 34;
    printf("%d, %d\n", c, d);
    return 0;
}

[A]. Error[B]. -11, 34
[C]. 11, 34[D]. None of these

Answer: Option A

Explanation:

Step 1: const c = -11; The constant variable 'c' is declared and initialized to value "-11".

Step 2: const int d = 34; The constant variable 'd' is declared as an integer and initialized to value '34'.

Step 3: printf("%d, %d\n", c, d); The value of the variable 'c' and 'd' are printed.

Hence the output of the program is -11, 34


Xyz said: (Tue, Apr 26, 2011 01:35:09 AM)    
 
In statement const c = -11, c will be declared as what data type. ?

Madhusudan said: (Thu, Jul 21, 2011 02:59:16 PM)    
 
By default it takes int.

Shahrukh said: (Tue, Aug 9, 2011 06:33:11 PM)    
 
Ya it will take int as the default data type.

Sunil Kumar Patel said: (Fri, Sep 16, 2011 10:45:25 AM)    
 
If we write that const d=-12; d will be treated as int data type. By default const is int data type.

Soumya said: (Fri, Oct 14, 2011 08:59:37 AM)    
 
Thanks Sunil.

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!