program 9. Write a program accept three numbers check whether   first number is between   other two. #include<stdio.h> void main...

 


program 9. Write a program accept three numbers check whether first number is between other two.

#include<stdio.h>

void main()

{

    int a,b,c;

    printf("Enter three numbers:");

    scanf("%d%d%d",&a,&b,&c);

    if(a<c && b<a)

    {

        printf("%d is between %d to %d \n",a,b,c);

    }

    else

    {

        printf("%d is not between %d to %d",a,b,c);

    }

}

Output

Enter three numbers:8 1 9

8 is between 1 to 9

  program 8: Accept a number check whether number is even. #include<stdio.h> int main() {                     int num;          ...



 program 8: Accept a number check whether number is even.

#include<stdio.h>

int main()

{

                int num;

                printf("\nEnter  Number:");

                scanf("%d", &num);

                if(num%2==0)

                {

                        printf("\n%d is Even",num);

                }

                else

                {

                        printf("\n%d is Odd",num);

                }

}

 Output    

[root@localhost Desktop]# cd ~/Desktop

[root@localhost Desktop]# gcc even.c

[root@localhost Desktop]#  ./a.out

Enter  Number:8

8 is Even

Program 7: Accept two integer from the user and interchange them display interchange number. #include<stdio.h> void main()...





Program 7: Accept two integer from the user and interchange them display interchange number.
#include<stdio.h>
void main()
{
int x,y,temp;
printf("Enter two numbers to interchange:");
scanf("%d%d",&x,&y);
temp=x;
x=y;
y=temp;
printf("\nInterchanged numbers are %d and %d",x,y);
}

Output
[root@dhcppc16 ~]# cd ~/Desktop
[root@dhcppc16 Desktop]# gcc tm.c
[root@dhcppc16 Desktop]# ./a.out
Enter two numbers to interchange:9 12
Interchanged numbers are 12 and 9


Program 6: Accept the x and y coordinates of two points and compute the distance between the two points. #include<stdio.h> ...





Program 6: Accept the x and y coordinates of two points and compute the distance between the two points.

#include<stdio.h>
#include<math.h>
int main()
{
float x1,x2,y1,y2,compute,distance;
printf("\nEnter values of x1 and y1:");
scanf("%d%d",&x1,&y1);
printf("\nEnter values of x2 and y2:");
scanf("%d%d",&x2,&y2);
compute=((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
distance=sqrt(compute);
printf("\nDistance=%f",distance);
}

 Output
[root@localhost ~]# cd ~/Desktop
[root@localhost Desktop]# gcc  distance.c
[root@localhost Desktop]# ./a.out
Enter values of x1 and y1:5 4
Enter values of x2 and y2:9 8
distance=5.656854

Program 5: Accept a character from the keyboard and display its previous and next character. #include<stdio.h> void main()...



Program 5: Accept a character from the keyboard and display its previous and next character.

#include<stdio.h>
void main()
{
    char ch;
    printf("Enter Character:");
    scanf("%c",&ch);
    printf("\nPrevious character of  %c is %c",ch,ch-1);
    printf("\nNext character of %c is %c",ch,ch+1);
}

Output
Enter Character: r
Previous character of r is q
Next character of r is s ✔




Program 4: Accept a character from the user and display its ascii value. #include<stdio.h> void main() { char ch; printf(...



Program 4: Accept a character from the user and display its ascii value.

#include<stdio.h>
void main()
{
char ch;
printf("Enter Character:");
scanf("%c",&ch);
printf("\nThe ASCII value of  %c is %d",ch,ch);
}

Output
Enter The Character: m
The ASCII value of  b is  98 ✔

HTML5 CSS3 TUTORIAL FOR BEGINNERS