• Trang chủ
  • Khóa học
  • Trang
    • Bài viết
    • Câu hỏi thường gặp
    • Điều khoản và Điều kiện
    • Thành viên trả phí
  • Về chúng tôi
  • Tài khoản
  • Liên hệ
Bạn có thắc mắc?
+84 38 213 5995
trieuthan92pro@gmail.com
Đăng kýĐăng nhập
Branium Academy
  • Trang chủ
  • Khóa học
  • Trang
    • Bài viết
    • Câu hỏi thường gặp
    • Điều khoản và Điều kiện
    • Thành viên trả phí
  • Về chúng tôi
  • Tài khoản
  • Liên hệ

    Bài tập lập trình C

    • Trang chủ
    • Blog
    • Bài tập lập trình C
    • Tính tổng cấp số cộng

    Tính tổng cấp số cộng

    • Posted by Thân Triệu
    • Phân loại Bài tập lập trình C
    • Date 22/08/2020
    • Các bình luận 29 Các bình luận

    Trong nội dung này ta sẽ viết chương trình giải quyết vấn đề: “Nhập số tự nhiên n rồi tính tổng: S = 1 + 2 + … + n“. 

    Để giải quyết vấn đề này có nhiều cách khác nhau: sử dụng vòng lặp, sử dụng công thức toán học. Trong cả hai cách chúng ta đều nhận được kết quả như nhau. Thuật toán và các bước thực hiện cụ thể như sau:

    Với cách sử dụng vòng lặp

    1. Khởi tạo biến tổng sum = 0, biến chạy i = 1
    2. Dùng vòng lặp for cho i chạy từ 1 đến n, cộng giá trị i vào tổng: sum += i
    3. hiện kết quả sum

    Với cách sử dụng công thức toán

    • Công thức tính cấp số cộng của bài này là: s = n(n+1)/2.
    • in ra kết quả

    Sau đây là chương trình thực hiện trên ngôn ngữ lập trình C:

    Như vậy chúng ta đã giải quyết xong vấn đề này rồi. Nếu có ý kiến đóng góp hay câu hỏi nào bạn hãy để lại phía dưới phần commnet nhé.

    Tag:Bài tập c, bài tập lập trình c, Beginner, tổng cấp số cộng

    • Share:
    author avatar
    Thân Triệu

    Previous post

    Phân loại tam giác
    22/08/2020

    Next post

    Tính tổng cấp số cộng phân số
    22/08/2020

    Có thể bạn quan tâm

    số thuận nghịch chia hết cho k
    Liệt kê các số thuận nghịch chia hết cho k
    24 Tháng Tám, 2020
    số đối xứng
    Kiểm tra số thuận nghịch
    23 Tháng Tám, 2020
    tính n giai thừa
    Tính tổng S = 1! + 2! + … + n!
    22 Tháng Tám, 2020

      29 Comments

    1. tuocthanh
      28/09/2020

      cho em hỏi sao mình lại dùng unsigned int thay vì int ạ

      • Thân Triệu
        28/09/2020

        Để tính tổng dương thôi e

    2. joker
      11/12/2020

      Thanks again for the blog. Much thanks again. Awesome. Katuscha Norton Zipah

    3. sex filmleri
      15/12/2020

      Thank you ever so for you article post. Really thank you! Great. Merilyn Arney Galen

    4. casino
      17/12/2020

      You made some fine points there. I did a search on the topic and found the majority of people will agree with your blog. Vanessa Ilario Lucinda

    5. bahis
      18/12/2020

      I really like and appreciate your article post. Thanks Again. Keep writing. Fawn Farrel Bear

    6. erotik
      18/12/2020

      Way cool! Some extremely valid points! I appreciate you writing this write-up and the rest of the website is really good. Bamby Thoma Oralee

    7. bahis
      18/12/2020

      Major thanks for the post. Really looking forward to read more. Really Cool. Hulda Kermit Babcock

    8. sikis
      18/12/2020

      I visited many blogs except the audio quality for audio songs current at this web site is truly fabulous. Perla Erhart Helbonnas

    9. sikis
      19/12/2020

      Hi there! This is kind of off topic but I need some guidance from an established blog. Jaquenetta Algernon Hatti

    10. erotik
      19/12/2020

      Remarkable! Its in fact amazing paragraph, I have got much clear idea about from this paragraph. Gussi Berty Fox

    11. bahis
      19/12/2020

      Although websites we backlink to beneath are considerably not associated to ours, we feel they are essentially really worth a go by, so have a look. Aurore Rossy Scammon

    12. sikis
      19/12/2020

      I think you have observed some very interesting points , appreciate it for the post. Farand Brant Higinbotham

    13. erotik
      19/12/2020

      Im thankful for the blog article. Much thanks again. Much obliged. Lynett Adams Berne

    14. bedava
      20/12/2020

      Thank you for your article. Thanks Again. Much obliged. Terrye Amory Dorsey

    15. web-dl
      20/12/2020

      I have read so many posts concerning the blogger lovers except this piece of writing is genuinely a nice article, keep it up. Ali Bernhard Tibbetts

    16. bedava
      20/12/2020

      Excellent way of describing, and good article to take information concerning my presentation subject, which i am going to present in school. Helen-Elizabeth Lindsey Santoro

    17. indir
      21/12/2020

      I used to be able to find good advice from your content. Kalie Rooney Willis

    18. yify
      21/12/2020

      Wonderful post! We are linking to this particularly great post on our site. Keep up the good writing. Frank Maddie Lorenzo

    19. download
      21/12/2020

      Really appreciate you sharing this blog. Really looking forward to read more. Awesome. Melinda Rollins Valer

    20. bedava
      22/12/2020

      This is one awesome blog article. Really thank you! Really Great. Merrili Reggy Car

    21. indir
      22/12/2020

      Now I am ready to do my breakfast, when having my breakfast coming over again to read other news. Nola Cross Ahl

    22. bedava
      23/12/2020

      Please stop by the sites we follow, which includes this one particular, because it represents our picks from the web. Arleyne Kleon Crooks

    23. emergency car locksmith
      03/01/2021

      I am incessantly thought about this, thanks for posting. https://local-auto-locksmith.co.uk/

    24. chwilówki dla zadłużonych
      03/01/2021

      I reckon something truly special in this website. https://chwilowki-pozyczka.pl/

    25. renault megane key
      03/01/2021

      Some really great info, Gladiola I detected this. I’m not spaming. I’m just saying your website is AWSOME! Thank you so much! Please vist also my website. https://local-auto-locksmith.co.uk/renault/

    26. clan symbol
      03/02/2021

      clan symbol knight online clanlar için ücretsiz bir paylaşım sitesidir.

    27. drugs used for thyroid problems
      15/02/2021

      Thanks for your thoughts. One thing I’ve got noticed is the fact banks in addition to financial institutions understand the spending behaviors of consumers and as well understand that the majority of people max out and about their cards around the breaks. They smartly take advantage of that fact and then start flooding ones inbox in addition to snail-mail box having hundreds of no interest APR credit cards offers shortly after the holiday season concludes. Knowing that should you be like 98% of American community, you’ll rush at the possiblity to consolidate card debt and shift balances for 0 apr interest rates credit cards. jiiihkm https://thyroidmedi.com – over counter medicine for thyroid pain https://thyroidmedi.com/

    28. buy thyroid pain drugs
      15/02/2021

      Thanks for your ideas. One thing I have noticed is that banks and financial institutions know the spending habits of consumers and understand that most people max out their credit cards around the holidays. They wisely take advantage of this fact and start flooding your inbox and snail-mail box with hundreds of 0 APR credit card offers soon after the holiday season ends. Knowing that if you are like 98% of the American public, you’ll jump at the chance to consolidate credit card debt and transfer balances to 0 APR credit cards. aaaaaaa https://thyroidmedi.com – buy thyroid pain drugs https://thyroidmedi.com/

    Search

    Chuyên mục

    • Bài tập C#
    • Bài tập lập trình C
    • Bài tập lập trình C phần cấu trúc rẽ nhánh
    • Bài tập lập trình C++
    • Bài tập lập trình Java
    • bài tập lập trình thân triệu
    • Bài tập phần mảng 1 chiều
    • Bài tập Python
    • Blog
    • Business
    • Design / Branding
    • giá trị min max
    • Hướng dẫn sử dụng hệ thống
    • Khảo sát
    • Uncategorized
    Khóa học Lập trình C cho người mới bắt đầu

    Khóa học Lập trình C cho người mới bắt đầu

    849,000₫ 512,000₫
    Khóa học lập trình Java từ cơ bản đến nâng cao

    Khóa học lập trình Java từ cơ bản đến nâng cao

    1,049,000₫ 709,000₫
    Khóa học lập trình C++ từ cơ bản đến nâng cao

    Khóa học lập trình C++ từ cơ bản đến nâng cao

    999,000₫ 649,000₫

    (+84) 38 213 5995

    trieuthan92@hotmail.com

    Branium Academy

    • Về chúng tôi
    • Bài viết
    • Liên hệ

    Liên kết

    • Khóa học
    • Các sự kiện
    • Câu hỏi thường gặp

    Hỗ trợ

    • Hỗ trợ Facebook
    • Hỗ trợ Teamviewer
    • Hỗ trợ Google Meet
    • Hỗ trợ Zoom

    Bản quyền © 2022 của Branium Academy. Bảo lưu mọi bản quyền.

    • Chính sách bảo mật
    • Điều khoản & Điều kiện
    • Sơ đồ trang
    • Các khóa học
    • Submissions
    • Password Recovery
    • Login

    Đăng nhập vào Branium Academy

    Quên mật khẩu?

    Chưa phải thành viên? Đăng ký ngay

    Đăng ký tài khoản mới

    Bạn đã có tài khoản? Đăng nhập ngay