fork download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. int val(int);
  4. int main()
  5. {
  6. int sc,v;
  7. printf(" Select your choice \n");
  8. printf("1.OK \n 2.ENTER your number \n ");
  9. scanf("%d",&sc);
  10. while(0)
  11. {
  12. switch(sc)
  13. {
  14. case 1: exit(0);
  15. case 2: val(v);
  16. break;
  17. default: printf("invalid option ");
  18. break;
  19. }
  20. }
  21. return 0;
  22. }
  23.  
  24. int val(int v)
  25. {
  26. int c,sum=0,n;
  27. printf("How many numbers you want to add?\n");
  28. scanf("%d", &n);
  29. printf("Enter %d integers\n", n);
  30. for (c = 1; c <= n; c++)
  31. {
  32. scanf("%d", &v);
  33. sum = sum + v;
  34. }
  35. return sum;
  36. }
Success #stdin #stdout 0s 5456KB
stdin
Standard input is empty
stdout
 Select your choice 
1.OK 
 2.ENTER your number