pages

Friday, 9 April 2021

c- program to print the middle dight of the three digit numbers in c-programing

 Q.no program to print the middle digit of the three digits number in c-programing?

We are here to print the middle digit of the three digits number by getting the values 

from the user.

suppose when the user enters the values of the number in variable 'a=352' then execute the second statement 'm=a/10%10' 

first m=   35%10                  (  a/10=352%10=35)

  then m=5                              ( a%10=35%10=5)                                      

                                                                                                                   

#include<stdio.h>
#include<conio.h>
main()
{
    int a,m;
    printf("enter three digit number");
    scanf("%d",&a);
    m=a/10%10;
    printf("the middle digit is %d",m);
    getch();
}

output:- the three digit number is 463
                the middle digit is 6.

No comments:

Post a Comment