3,484 views
1 1 vote
  1.  #include <stdio.h>
  2.     int main()
  3.     {
  4.         int a = 4, n, i, result = 0;
  5.         scanf("%d", n);
  6.         for (i = 0;i < n; i++)
  7.         result += a;
  8.     }

what is o/p 

a) Addition of a and n.
b) Subtraction of a and n.
c) Multiplication of a and n.
d) Division of a and n.

anyone plz expalin 

1 Answer

4 4 votes
assume n=3

i=0  ;r=0+4=4;

i=1  ;r=4+4=8;

i=2  ;r=8+4=12;

i=3  loop exit;

you can see final result r=12 is multiplication of a and n.
Position:
Show:

Related questions

9 9 votes
6 6 answers
986
986 views
GO Classes asked Jul 25, 2025
986 views
#include <stdio.h void fun() { static int count = 0; count++; printf("%d ", count); } int main() { for (int i = 0; i < 3; i++) fun(); return 0; }What is the output of the...
6 6 votes
3 3 answers
683
683 views
GO Classes asked Jul 25, 2025
683 views
Given the pseudocode below for the function remains(), which of the following statements is true about the output, if we pass it a positive integer $n>2$ ? int remains(in...
7 7 votes
4 4 answers
751
751 views
GO Classes asked Jul 19, 2025
751 views
int arr[ ]={1, 2, 3, 4} int count; incr( ) {return ++count;} main( ) { arr[count++]=incr( ); printf("arr[count]=%d\n", arr[count]); }The value printed by the above progra...