Saturday, October 24, 2020

If the given number is positive, display the square and the cube otherwise display an error (C program)

#include <stdio.h>

int main() {

    int n;

    printf("Enter a number:");

    scanf("%d",&n);

    if(n>0)

    {

        printf("Square=%d, Cube=%d",n*n,n*n*n);

    }

    else

    {

        printf("Enter a positive number");

    }

}

No comments:

Post a Comment

How to Fight Overthinking or Negative Thoughts?

How to Combat Overthinking or Negative Thoughts? 1. Don’t Fight Your Thoughts Trying to suppress or control negative thoughts often backfire...