How to use find the product of digits of any number in c language

program to use find the product of digits of any number in c language


#include <stdio.h>
int main()
{
    int n, prod = 1, rem;
    printf("enter a number : ");
    scanf("%d", &n);
    while (n > 0)
    {
        rem = n % 10;
        prod *= rem;
        n /= 10;
    }
    printf("product of digits = %d\n", prod);
    return 0;
}

output


enter a number : 166
product of digits = 36

How to use leap year in c language

program to use leap year in c language


#include <stdio.h>
int main()
{
    int year;
    printf("enter year : ");
    scanf("%d", &year);
    if (year % 100 != 0)
    {
       
        if (year % 4 == 0)
        {
            printf("leap year\n");
        }
        else
        { 
            printf("not leap\n");
        }
    }
    else
    {
        if (year % 400 == 0){
            printf("leap year\n");
        }
        else
            printf("not leap\n");
    }
    return 0;
}

output


enter year : 2028
leap year

How to use quotient and remainder in C Language

Program to use quotient and remainder in C Language


#include <stdio.h>
int main()
{
    int x, y, quo, rem;
    printf("Enter two number : ");
    scanf("%d%d", &x, &y);
    if (y)
    {
        quo = x / y;
        rem = x % y;

        printf("Quotient = %d,remainder=%d\n", quo, rem);
    }
    else
    {
        printf("Divide by zero error\n");
    }
    return 0;
}

output


Enter two number : 44
6
Quotient = 7,remainder = 2

Steps / Description

  1. Declare integer variable x, y, quo, rem
  2. printf inbuild function to display will give two numbers
  3. Pass to values to scanf
  4. If condition
  5. which will give value divided into x and y
  6. printf inbuild function to display the value of quo ,rem

how to use negative a number in c language

program to use negative a number in c language


#include<stdio.h>
int main()
{
    int num;
    printf("Enter a number : ");
     scanf("%d",&num);
     if(num<0)
     {
        printf("Number entered is negative\n");
        num=-num;
     }
     printf("value of num is : %d\n",num);
     return 0;
}

output


Enter a number : -4
Number entered is negative
value of num is : 4