Advertisement
Robert_Manea

suma primelor nr cu do while

Nov 12th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int n,s=0,i=0;
  7. printf("Introducti n: ");
  8. scanf("%d",&n);
  9. do{
  10. s=s+i;
  11. i++;
  12. }
  13. while(i<=n);
  14.  
  15. printf("Suma primelor %d numere este : %d\n",n,s);
  16.  
  17.  
  18. return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement