Interview Questions on C C++

Home  |  About Us  |  Contact
View Questions Contribute Training Misc..

C++ program to find sum of n numbers using function

#include <stdio.h>
#include <conio.h>

int sum (int number);

int main()
  int no;

  printf("\n How many numbers? : ");
  scanf("%d", &no);

  printf("\n Sum of the %d numbers is : %d ",no,sum(no));
  return 0;
int sum(int number){

  int i, addition=0;

  for(i=1; i<=number; i++){
    addition += i;
  return addition;