3,477 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

8 8 votes
6 6 answers
948
948 views
GO Classes asked Jul 25, 2025
948 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...
5 5 votes
3 3 answers
664
664 views
GO Classes asked Jul 25, 2025
664 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...
6 6 votes
4 4 answers
730
730 views
GO Classes asked Jul 19, 2025
730 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...