All India Exams
  • Sign In / Register Sign In
Home AptitudeBankEngineeringEnglishGKInterviewOnline TestPlacement PapersReasoning
  • Home
  • Aptitude
  • Bank
  • Engineering
  • English
  • GK
  • Interview
  • Online Test
  • Placement Papers
  • Reasoning

Declarations C Questions And Answers

Here you can find Declarations C Questions and Answers.

Why Declarations C Questions and Answers Required?

In this Declarations C Questions and Answers section you can learn and practice Declarations C Questions and Answers to improve your skills in order to face technical inerview conducted by Banks. By Practicing these interview questions, you can easily crack any Bank Exams interview.

Where can I get Declarations C Questions and Answers?

AllIndiaExams provides you lots Declarations C Questions and Answers with proper explanation. Fully solved examples with detailed answer description. All students, freshers can download Declarations C Questions and Answers as PDF files and eBooks.

How to solve these Declarations C Questions and Answers?

You no need to worry, we have given lots of Declarations C Questions and Answers and also we have provided lots of FAQ's to quickly answer the questions in the Bank Exams interview.

Declarations C Questions and Answers

1. What is the output of this C code? void foo(const int *); int main() { const int i = 10; printf("%d ", i); foo(&i); printf("%d", i); } void foo(const int *i) { *i = 20; }

Declarations C Questions and Answers

2. Comment on the output of this C code? int main() { const int i = 10; int *ptr = &i; *ptr = 20; printf("%d\n", i); return 0; }

Declarations C Questions and Answers

3. What is the output of this C code? int main() { j = 10; printf("%d\n", j++); return 0; }

Declarations C Questions and Answers

4. Does this compile without error? int main() { for (int k = 0; k < 10; k++); return 0; }

Declarations C Questions and Answers

5. Does this compile without error? int main() { int k; { int k; for (k = 0; k < 10; k++); } }

Declarations C Questions and Answers

6. Which of the following declaration is not supported by C?

Declarations C Questions and Answers

7. Which of the following format identifier can never be used for the variable var? int main() { char *var = "Advanced Training in C by AllIndiaExams.com"; }

Declarations C Questions and Answers

8. Which of the following declaration is illegal?

Declarations C Questions and Answers

9. Which keyword is used to prevent any changes in the variable within a C program?

Declarations C Questions and Answers

10. Which of the following is not a pointer declaration?

Home Declarations

Declarations - C Multiple Choice Questions and Answers

This is the c programming questions and answers section on "Declarations and Initializations" with explanation for various interview, competitive examination and entrance test. Solved examples with detailed answer description, explanation are given and it would be easy to understand. What are Declarations in C Langauge? Are you ready to know about it? Then check this article to find the Declarations C Questions. Contenders can refer to the last portion of this page to see the Declarations C Online Test. For all the applicants the arranged Declarations C Quiz will be available for free of cost. So, the postulates can learn the Declarations C Questions and Answers by taking part in the mock test. In the below table, we have provided all the information related to the Declarations C MCQ Quiz. Thus, the competitors can check and prepare the multiple choice questions regarding Declarations in C Langauge.



Declarations C Questions - Declarations C Quiz Details

Online Test Name Declarations
Exam Type Multiple Choice Questions
Category Computer Science Engineering Quiz
Number of Questions 14


Contenders can learn the basic to the high-level concepts of the Declarations in C by practicing the Declarations C Online Tests. On this page, the candidates can find the Declarations C Quiz to prepare for the examinations. Thus, the applicants who are interested in preparing for the interviews can practice the arranged Declarations C Mock Test. By this, the aspirants can learn the various questions related to the Declarations in C Programming. Hence, the candidates need to take part in the Declarations C Online Test without any time waste. In addition to this, the students need to know the difference between the Declarations and Definitions in C.



Declarations C Multiple Choice Questions

From this section, the applicants can check the Declarations C Multiple Choice Questions. The contenders can practice the Declarations C Online Test to know and learn all the questions and answers. With the help of this page, the students can get 10+ Declarations C Questions to practice. So, the competitors can check all the questions which are given in the Declarations C Quiz and prepare for the examinations. Scroll down the page and take part in the Declarations C Online Test without any delay. By practicing the quizzes and online tests, the aspirants can quickly answer the question at the time of the examination.

Declarations MCQ Quiz Answers with Solutions

Use the "View Answer" button to know the right choice among all along with the explanation of the question. For all the Declarations C Questions, we have arranged the solutions in this article. Thus, the applicants can take it as a practice session and learn all the concepts related to the Declarations in C. And, follow our web portal @ Allindiaexams.in to check the regular updates.


1. What is the output of this C code?

void foo(const int *);
int main()
{
const int i = 10;
printf("%d ", i);
foo(&i);
printf("%d", i);
}
void foo(const int *i)
{
*i = 20;
}
  • A. Compile time error
  • B. 10    20
  • C. Undefined value
  • D. 10
  • View Answer
  • Workspace
  • Report
  • Discuss

Answer & Explanation

Answer: Option A

Explanation:

Cannot change a const type value.
Output:
$ cc pgm1.c
pgm1.c: In function ‘foo’:
pgm1.c:13: error: assignment of read-only location ‘*i’

Workspace

Report Error


2. Comment on the output of this C code?

int main()
{
const int i = 10;
int *ptr = &i;
*ptr = 20;
printf("%d\n", i);
return 0;
}
  • A. Compile time error
  • B. Compile time warning and printf displays 20
  • C. Undefined behaviour
  • D. 10
  • View Answer
  • Workspace
  • Report
  • Discuss

Answer & Explanation

Answer: Option B

Explanation:

Changing const variable through non-constant pointers invokes compiler warning
Output:
$ cc pgm2.c
pgm2.c: In function ‘main’:
pgm2.c:5: warning: initialization discards qualifiers from pointer target type
$ a.out
20

Workspace

Report Error


3. What is the output of this C code?

int main()
{
j = 10;
printf("%d\n", j++);
return 0;
}
  • A. 10
  • B. 11
  • C. Compile time error
  • D. 0
  • View Answer
  • Workspace
  • Report
  • Discuss

Answer & Explanation

Answer: Option C

Explanation:

Variable j is not defined.
Output:
$ cc pgm3.c
pgm3.c: In function ‘main’:
pgm3.c:4: error: ‘j’ undeclared (first use in this function)
pgm3.c:4: error: (Each undeclared identifier is reported only once
pgm3.c:4: error: for each function it appears in.)

Workspace

Report Error


4. Does this compile without error?

int main()
{
for (int k = 0; k < 10; k++);
return 0;
}
  • A. Yes
  • B. No
  • C. Depends on the C standard implemented by compilers
  • D. None of the mentioned
  • View Answer
  • Workspace
  • Report
  • Discuss

Answer & Explanation

Answer: Option C

Explanation:

Compilers implementing C90 does not allow this but compilers implementing C99 allow it.
Output:
$ cc pgm4.c
pgm4.c: In function ‘main’:
pgm4.c:4: error: ‘for’ loop initial declarations are only allowed in C99 mode
pgm4.c:4: note: use option -std=c99 or -std=gnu99 to compile your code

Workspace

Report Error


5. Does this compile without error?

int main()
{
int k;
{
int k;
for (k = 0; k < 10; k++);
}
}
  • A. Yes
  • B. No
  • C. Depends on the compiler
  • D. Depends on the C standard implemented by compilers
  • View Answer
  • Workspace
  • Report
  • Discuss

Answer & Explanation

Answer: Option A

Explanation:

There can be blocks inside block and within blocks variables have only block scope.
Output:
$ cc pgm5.c

Workspace

Report Error


  • «
  • 1
  • 2
  • 3
  • »

Related Topics:

  • Typedef
  • Storage Management
  • Standard Input and Output
  • C Operators
  • Preprocessor
  • Conditional Expressions
  • Structures, Unions, Bit-fields
  • Pointers
  • C Functions
  • C Data Types

Mock Tests & Online Quizzes

  • Aptitude Online Test

  • Reasoning Online Test

  • GK Online Test

  • English Online Test

  • RRB Mock Test

  • RBI Mock Test

  • Free SBI Mock Test

  • IBPS Mock Test FREE

  • SSC Mock Test

  • CAT Exam Mock Test

  • GATE Mock Test

  • LIC Mock Test Series

  • MAT Mock Test

  • SEBI Mock Test

  • ESIC Mock Test

  • IT Courses Quiz

Newsletter

Contact Us

Questions and Answers

  • Aptitude Questions
  • Verbal Reasoning Questions
  • Non Verbal Reasoning Questions
  • Logical Reasoning Questions
  • Data Sufficiency Questions
  • Data Interpretation Questions
  • C Programming
  • C++ Programming
  • PHP Programming
  • Java Programming
  • eLitmus Sample Papers
  • ECE Questions and Answers
  • EEE Questions and Answers
  • Verbal Ability Questions
  • GK Questions
  • AMCAT Mock Online Test
  • LIC Mock Test
  • IBPS Mock Test

Interview Questions

  • Java Interview Questions
  • .Net Interview Questions
  • Networking Interview Questions
  • C Language Interview Questions
  • C++ Interview Questions
  • Testing Interview Questions
  • Android Interview Questions
  • HR Interview Questions
  • Group Discussion Topics
  • iOS Interview Questions
  • Web Technologies
  • Database Interview Questions
  • MS Office Interview Questions
  • Software Tools
  • Data Interpretation
  • PHP Interview Questions
  • CAT Mock Test
  • SSC Mock Test
© by AllIndiaExams.in. All Rights Reserved | Copyright | Terms of Use & Privacy Policy