Git Product home page Git Product logo

hw080920's Introduction

HW 08/09/20

  1. Greatest of two
    #include<stdio.h>

    main()
    {
	    int n1, n2;
	    printf("Please enter two numbers: ");
	    scanf("%d%d",&n1,&n2);
	    if( n1 > n2 )
		    printf("%d is greater than %d\n",n1,n2);
	    else
		    printf("%d is greater than %d\n",n2,n1);
    }

Output Image

  1. Greatest of three
    #include "stdio.h"

    main()
    {
	    int n1,n2,n3,max;
	    printf("Please enter three numbers: ");
	    scanf("%d%d%d",&n1,&n2,&n3);
	    if(n1>n2 && n1>n3)
		    max = n1;
	    else if(n2>n3)
		    max=n2;
	    else
		    max=n3;
	    printf("%d is the greatest of all!\n",max);
    }

Output Image

  1. Odd or even
    #include "stdio.h"

    main()
    {
	    int n;
	    printf("Please enter a number: ");
	    scanf("%d",&n);
	    if(n%2==0)
		    printf("%d is even\n",n);
	    else
		    printf("%d is odd\n",n);
    }

Output Image

  1. Find the largest of two lengths
    #include "stdio.h"

    main()
    {
	    float f1,f2,i1,i2;
	    printf("Please enter the first length in Feet and Inch: ");
	    scanf("%f%f",&f1,&i1);
	    printf("Please enter the second length in Feet and Inch: ");
	    scanf("%f%f",&f2,&i2);
	    i1+=f1*12;
	    i2+=f2*12;
	    if(i1>i2)
		    printf("Length #1 is greater\n");
	    else
		    printf("Length #2 is greater\n");
    }

Output Image

  1. Check whether a time is AM or PM
    #include "stdio.h"

    main()
    {
	    int h;
	    printf("Please enter the time in HH format: ");
	    scanf("%d",&h);
	    h=h%24;
	    if(h>12)
		    printf("PM\n");
	    else
		    printf("AM\n");
    }

Output Image

  1. Check whether a year is leap year or not
    #include "stdio.h"

    main()
    {
	    int y;
	    printf("Please enter a year: ");
	    scanf("%d",&y);
	    if(y%4==0 && y%100!=0 || y%400==0)
		    printf("%d is a leap year\n",y);
	    else
		    printf("%d is not a leap year\n",y);
    }

Output Image

  1. Find the smallest of four numbers
    #include "stdio.h"

    main()
    {
	    int n1,n2,n3,n4,min;
	    printf("Please enter four numbers: ");
	    scanf("%d%d%d%d",&n1,&n2,&n3,&n4);
	    if(n1<n2 && n1<n3 && n1<n4)
		    min = n1;
	    else if(n2<n3 && n2<n4)
		    min=n2;
	    else if(n3<n4)
		    min=n3;
	    else
		    min=n4;
	    printf("%d is the smallest\n",min);
    }

Output Image

hw080920's People

Contributors

banerjee-indra avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.