Guest User

Untitled

a guest
Nov 16th, 2020
24
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int intN,intCounter, flag;
  6. unsigned long int ulngSum;
  7. char ch ;
  8.  
  9. do{
  10. do{
  11. flag=0;
  12. printf("Enter a number (0<n<30000):");
  13. scanf("%d", &intN);
  14. if((intN <=0) || (intN > 30000))
  15. flag = 1;
  16. }while(flag);
  17.  
  18. ulngSum=0;
  19.  
  20. for(intCounter = 1; intCounter<= intN; intCounter++)
  21. {
  22. ulngSum=ulngSum + intCounter;
  23.  
  24. }
  25.  
  26. printf("Required sum is :%lu\n", ulngSum);
  27. printf("do you want to continue? (Y/N) : \n");
  28. scanf(" %c", &ch);
  29.  
  30.  
  31. }while ((ch=='y') || (ch=='Y'));
  32.  
  33. printf("Thank you.\n");
  34.  
  35. return 0;
  36. }
  37.  
  38.  
  39.  
RAW Paste Data