aliensbrain
  • Home
  • Study
  • Quizzes
  • 🎤AI Practicefree
  • Notebooks
  • Community
  • Sign in
  • Programming (C/C++)
  • What will be the output of the following function? main()...
Multiple choice

What will be the output of the following function?

main() { int a[10]; printf(%d,*a+1-*a+3); }

  1. Garbage value

  2. 4

  3. Error

  4. None of these

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The expression *a + 1 - *a + 3 simplifies mathematically because the terms *a and -*a cancel each other out. This leaves 1 + 3, which results in 4, regardless of the values stored in the array.

Keep practicing — related questions

  • What will be the output of the following function? main() { int i; printf(%d,scanf(%d,&i)); // value 10 is ...
  • What would be the output of the following program? main() { int a[5] = {2,3};; printf("\n%d %d %d", a[2],a[...
  • What will be the output of the following: void main() { register int a; printf("%d",a); }
  • What will be the output of the following set of codes after execution? void main() { printf(“%d”,sizeof(' '...
  • Find the output of the following C program: main(){int a[5]={2,3};printf(%d%d%d,a[2],a[3],a[4]);}
  • What is the output of following code snippet ? void main() { int arr[5]={10,20,30,40,50}; printf("%d",(arr+...
  • What will be the output of the following function? # include <stdio.h> void main() { int a[5] = {5,1,15,20,...
  • void main() { int a[2][3]={{1,2,3},{4,5,6}}; printf("%d\n",++**(a+1)); }
Play the full quiz 🎤 Practise this topic out loud
Advertisement
© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy