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

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

Bài tập 48 (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ố lẻ của số nguyên dương n

Cài đặt

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
    long themang, n;
    int sochuso;
    int P = 1;
    do
    {
    printf("\nNhap n: ");
    scanf("%ld", &n);
    }while(n < 0 && printf("\nLoi: n >= 0 !"));
    sochuso = 0;
    themang = n;

    while(themang != 0)
    {
        if(themang % 2 == 1)
        {
         P = P * (themang % 10);
        }
        themang = themang / 10;
    }
    printf("\nTich cac chu so le cua %ld la %d", n, P);

    

    getch();
    return 0;
}
Bạn thấy bài viết này như thế nào?: 
Average: 9.8 (11 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

 
Giới thiệu tổng quan Drupal 8 services năm 2015

Giới thiệu tổng quan Drupal 8 services năm 2015

In this post we’ll look at a simple way to override services using aliases

Kingston ra mắt USB “Phi Mã” phiên bản giới hạn cho năm mới 2014

Kingston ra mắt USB “Phi Mã” phiên bản giới hạn cho năm mới 2014

Ngày 24/12, Kingston chính thức ra mắt mẫu USB “Phi Mã” phiên bản giới hạn và đó cũng là sản phẩm mới nhất thuộc dòng USB Kingston DataTraveler 12 Con Giáp.

Đã có bản Webprofiler toolbar cho  Drupal 8

Đã có bản Webprofiler toolbar cho Drupal 8

As someone working on some drupal site you often want to understand what happens on a specific site. This blog post will describe a tool which helps to understand the site faster and easier.

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

 

Diet con trung