fork download
  1. // C code
  2.  
  3. // This program will calculate the sum of 10 positive integers.
  4.  
  5. // Developer: Faculty CMIS102
  6.  
  7. // Date: Jan 31, XXXX
  8.  
  9. #include <stdio.h>
  10.  
  11. int main ()
  12.  
  13. {
  14.  
  15. /* variable definition: */
  16.  
  17. int EndNum,CurrentNum,NegNum;
  18. CurrentNum=0;
  19.  
  20.  
  21. /* Initialize */
  22.  
  23.  
  24. printf("Enter A positive whole number you want to count to.\n");
  25. printf("OR\n");
  26. printf("A negitive whole number that you want to count to zero with.\n");
  27.  
  28. scanf("%d", &EndNum);
  29. // Loop through to input values
  30.  
  31. while(EndNum>CurrentNum)
  32.  
  33. {
  34. if (EndNum > CurrentNum) {
  35. CurrentNum = 1 + CurrentNum;
  36. printf("%d",CurrentNum);
  37. printf(" ");
  38. }
  39.  
  40.  
  41. else {
  42. printf("%d",EndNum);
  43. printf(" ");
  44. NegNum=EndNum;
  45.  
  46. while(NegNum<0){
  47. NegNum = 1 + NegNum;
  48. printf("%d",NegNum);
  49. printf(" ");
  50. }
  51. }
  52.  
  53. }
  54.  
  55.  
  56.  
  57.  
  58.  
  59. return 0;
  60. }
  61.  
Success #stdin #stdout 0s 10320KB
stdin
-2
stdout
Enter A positive whole number you want to count to.
OR
A negitive whole number that you want to count to zero with.