Bài tập 45: Hãy tính tích các chữ số của số nguyên dương n

Bài tập 45: Hãy tính tích các chữ số của số nguyên dương n

Bài tập 45 (Dạng bài tập này giúp các bạn giỏi về: Lưu đồ thuật toán)

Hãy tính tích các chữ số của số nguyên dương n

Cài đặt

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
    int themang, n;
    int P;

    do
    {
    printf("\nNhap n: ");
    scanf("%d", &n);
    }while(n < 0 && printf("\nLoi: n >= 0 !"));
    P = 1;
    themang = n;

    while(themang != 0)
    {
        P = P * (themang % 10);
        themang = themang / 10;
    }
    printf("\nTich la %d", P);

    getch();
    return 0;
}
Bạn thấy bài viết này như thế nào?: 
Average: 6.1 (7 votes)
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Hướng dẫn tạo Drupal 7 Content Type Search Block chỉ với 5 Steps

Hướng dẫn tạo Drupal 7 Content Type Search Block chỉ với 5 Steps

Since the content type I needed to search for was already indexed by the search module, I wanted to stick with core Drupal searching. I didn’t really want to mess with altering an advanced search form, so I came up with the following solution, which only took 5 easy steps.

Sự khác biệt Entity Property API ở Drupal 8 và Drupal 7

Sự khác biệt Entity Property API ở Drupal 8 và Drupal 7

While the conversion to full CRUD for entities and classed objects for Drupal 8 made good progress

Trình duyệt nào là số 1 trên iOS

Trình duyệt nào là số 1 trên iOS

Ngày nay, không chỉ cuộc chạy đua giữa các smartphone đang trở nên khốc liệt mà ngay cả ngành công nghiệp sản xuất phần mềm di động cũng nóng hơn bao giờ hết.

Công ty diệt chuột T&C

 

Diet con trung