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

All Quotes

 Quote 53: Ethical earning is key. Quote 52: Grades matter, but your skills, curiosity, and consistency matter even more. Quote 51: Be curio...