Find the output for the following C program#include<stdio.h>void main(void);{void pa(int *a,int n);int arr[5]={5,4,3,2,1};pa(arr,5);}void pa(int *a,int n){int i;for(i=0;i<n;i++)printf("%dn",*(a++)+i);}

Showing Answers 1 - 2 of 2 Answers

sucheta

  • Feb 24th, 2006
 

compute for every i and then increment a for every i. then add both the results. like......i=0 a=0 => 0+5i=1 a=1 => 1+4and so on. till the conditon fails......then the sum will be 5+5+5+5+5+5=30;reply back if the answer is correct. and any other advices

  Was this answer useful?  Yes

ALOK SHAKYA

  • Aug 7th, 2007
 

Ans should be
    5
    5
    5
    5
    5
We are printing each element in each step not the sum.                  

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions