Search This Blog

Sunday, 17 May 2020

programming C(small value and largest value)

    largest value and smallest value among the three numbers(if and switch content)

#include<stdio.h>
#include<stdlib.h>

int main()
{
    int no1,no2,no3;
    printf("Enter three numbers\n");
    scanf("%d %d %d",&no1,&no2,&no3);

    if(no1<no2 && no1<no3)
    {
            printf("%d is the smallest number\n",no1);
    }
    else if(no2<no3)
    {
        printf("%d is the smallest number\n",no2);
    }
    else
    {
        printf("%d is the smallest number\n",no3);
    }

    if(no1>no2 && no1>no3)
    {
    printf("%d is the largest number",no1);
    }
    else if(no2>no3)
    {
    printf("%d is the largest number",no2);
    }
    else
    {
    printf("%d is the largest number",no3);
    }
    return 0;
}

    

programming C(high number)

  Write a program to input two numbers and display the highest number (if content)


 #include <stdio.h>
    #include <stdlib.h>

    int main()
    {

      int no1,no2,max;
      printf("enter two numbers \n");
      scanf("%d %d",&no1,&no2);
      max=no1;
      if(no2>max)
      max=no2;

      printf("the highest is %d\n",max);

     }