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

Are We Putting Effort in the Right Direction? ❤️ | A Life Lesson About Effort & Strategy ✨

  https://youtube.com/shorts/MMo2JOc3mzc Hey. So, uh recently I was in a discussion with my brother, elder brother, let's say. And we we...