NPTEL » Problem Solving Through Programming In C Week-03: Program-01 02 03 and 04

Week-03: Program-01


 #include <stdio.h>

#define PI 3.14

void main()

{

    int radius;

    float area;

    /* Enter the radius of a circle */

    scanf("%d", &radius);

    area = PI * radius * radius;

    printf("Area of a circle = %5.2f", area);

}

Week-03: Program-02

#include <stdio.h>

int main()

{

    double number;

    scanf("%lf", &number);

    if(number <= 0.0)

    {

        if (number == 0.0)

            printf("The number is 0.");

        else

            printf("Negative number.");

    }

    else

        printf("Positive number.");

}

Week-03: Program-03

#include <stdio.h>

int main()

{

    int number;

    scanf("%d", &number);

     if(number % 2 == 0)

    printf("%d is even.", number);

    else

    printf("%d is odd.", number);

}

Week-03: Program-04

#include <stdio.h>

int main()

{

    int n1, n2, n3;


    scanf("%d %d %d", &n1, &n2, &n3);

    if( n1>=n2 && n1>=n3 )

        printf("%d is the largest number.", n1);


    if( n2>=n1 && n2>=n3 )

        printf("%d is the largest number.", n2);


    if( n3>=n1 && n3>=n2 )

        printf("%d is the largest number.", n3);


}

No comments

JavaFX Scene Builder

  This is an article about the JavaFX Scene Builder. You will get a short introduction about the installation and usage of the software. The...