How to use bigger number in C Language

Program to use if-else in C Language


#include <stdio.h>
int main()
{
    int a, b;
    printf("Enter a two numbers : ");
    scanf("%d%d", &a, &b);
    if (a > b)
    {
        printf("Bigger number=%d\n", a);
    }
    else
    {
        printf("Bigger number=%d\n", b);
    }
    return 0;
}

output


Enter two numbers : 15
10
Bigger number=15

Steps / Description

  1. Declare integer variable a and b
  2. printf inbuild function to display two numbers
  3. Will print the value given by scanf
  4. if statement a grater b
  5. printf inbuild function to display bigger number variable a

How to use sum of digits of any number in c language

program to use sum of digits of any number in c language


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

output


enter a number : 55
sum of digits = 10

How to use floating arithmetic operator in c language

program to use floating arithmetic operator c language


#include<stdio.h>
int main()
{
    float a=12.4,b=3.8,s;
    s=a+b;
    printf("sum=%.2f\n",s);
    s=a-b;
    printf("difference=%.2f\n",s);
    s=a*b;
    printf("product=%.2f\n",s);
    s=a/b;
    printf("a/b=%.2f\n",s);
    return 0;
}

output


sum=16.20
difference=8.60
product=47.12
a/b=3.26

Steps Description

  1. Declare float three variable a , b and s
  2. Initialize in float variable a=12.4 b=3.8
  3. Assign S variable with sum of variable a and b
  4. printf inbuild function display S variable with decimal placeholder %d
  5. Assign S variable with difference of variable a and b
  6. printf inbuild function display S variable with decimal placeholder %d
  7. Assign S variable with product of variable a and b
  8. printf inbuild function display S variable with decimal placeholder %d
  9. Assign S variable with a/b of variable a and b
  10. printf inbuild function display S variable with decimal placeholder %d

How to use size of operator in C Language

program to us size of operator in C Language


#include <stdio.h>
int main()
{
    int var;
    printf("size of int=%u\n", sizeof(int));
    printf("size of float=u\n", sizeof(float));
    printf("size of var=%u\n", sizeof(var));
    printf("size of an integer constant =%u\n", sizeof(45));
    return 0;
}

output


size of int =4
size of float=u
size of var = 4
size of an integer constant =4

Step / Description

  1. Declare integer variable "var"
  2. printf inbuild function to display size of integer variable "var" using another inbuilt function ""size of()"
  3. printf inbuild function to display size of float variable "var" using another inbuild function "size of()"
  4. printf inbuild function to display size of var variable "var" using another inbuild function "size of()"
  5. printfinbuild function to display size of an integer constant variable "var" using another inbuild function "size of()"

How to use while loop in c language

program to use while loop is c language


#include <stdio.h>
int main()
{
    int i = 1;
    while (i <= 10)
    {
        printf("%d\t", i);
        i = i + 1;
    }
    printf("\n");
    return 0;
}

output


1       2       3       4       5       6       7       8       9       10

Steps Description

  1. Declare integer variable i
  2. initialize integer variable i=1
  3. whil (i=5) condition which needs to be evaluated
  4. printf inbuild function to display the value of %d
  5. code of instructions which need to be executed
  6. i++ increment value

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 : 65
5
quotient = 13,remainder=0

How to use size of operators in c language

program to use size of operators in c language


#include<stdio.h>
int main()
{
    int var;
    printf("size of int =%u\n",sizeof(int));
    printf("size of float=%u\n",sizeof(float));
    printf("size of var=%u\n",sizeof(var));
    printf("size of an integer constant=%u\n",sizeof(45));
    return 0;

}

output


size of int =4
size of float=4
size of var=4
size of an integer constant=4

Steps Description

  1. Declare integer variable var
  2. printf inbuild function to display size of integer variable "var" using another inbuild function "size of()
  3. printf inbuild function to display size of float variable "var" using another inbuild function "size of()
  4. printf inbuild function to display size of"var" variable using another inbuild function size of()
  5. printf inbuild function to display size of in integer variable "var" using another function size of()

Postfix increment decrement in C Language

Program use increment decrement in C Language


#include <stdio.h>
int main()
{
    int x = 8;
    printf("x=%d\t", x);
    printf("x=%d\t", x++);
    printf("x=%d\t", x);
    printf("x=%d\n", x--);
    printf("x=%d\n", x);
    return 0;
}

output


x=8  x=8  x=9  x=9  x=8  

  1. Declare integer variable x = 8
  2. Initialize in integer variable x = 8
  3. printf inbuild function to display value of variable x in decimal place holder %d x = 8 for formatting tab separator \t is used
  4. printf inbuild function to display postfix increment values variable x in decimal place holder %d x = 8 for formatting tab separator \t is used
  5. printf inbuild function to display value of variable x int decimal place holder %d x = 9 for formatting tab separator \t is used
  6. printf inbuild function to display post decrement values variable x in decimal place holder %d x = 9 for formatting tab separator \t is used
  7. printf inbuild function to display value of variable x in decimal place holder %d x = 8 for formatting tab separator \t is used

How to use prefix increment decrement in C Language

Program to use prefix increment decrement in C Language


#include <stdio.h>
int main()
{
    int x = 8;
    printf("x=%d\t", x);
    printf("x=%d\t", ++x);
    printf("x=%d\t", --x); 
    printf("x=%d\n", x);
    return 0;
}

output


x=8  x=9  x=8  x=8

Steps/Description

  1. Declare integer variable x = 8
  2. Initialize in integer variable x = 8
  3. printf inbuild function to display value of variable x in decimal place holder %d = x for formatting tab separate or \t is used
  4. printf inbuild function to display prefix increment value variable x in decimal place holder %d = 9 for formatting tab separate or \t is used
  5. printf inbuild function to display variable x in decimal place holder %d = 9 for formatting tab separate or \t is used
  6. printf inbuild function to display prefix decrement x in decimal place holder %d x = 8 for formatting tab separate or \t is used
  7. printf inbuild function to display variable x in decimal place holder %d x = 8 for formatting tab separate or \t is used