Telaryon

Egyszerű példa a do while ciklus használatára

Mar 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.27 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void){
  4.     int N;
  5.     int sum=0;
  6.  
  7.         printf("\nKerek egy szamot. ");
  8.         scanf("%d", &N);
  9.         do{
  10.             sum+=N;
  11.             N--;
  12.         } while (N>0);
  13.             printf("\nOsszeg: %d\n", sum);
  14.     return 0;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment