Computer Science, asked by kajalsingh990, 7 days ago

Write a program in python to check if the number is even or odd and if even calculate square and if odd calculate cube

Answers

Answered by shouryadagar8thc38st
3

Answer:

#include<stdio.h>

int main ()

{

int max,i;

printf("Enter the number upto which the squares of even number and cubes of odd number to be printed:");

scanf("%d",&max);

for(i=1;i<=max;i++)

{

if(i%2==0)

printf("%d ",i*i);

else

printf("%d ",i*i*i);

}

}

Hope you understand the code.

Answered by Anonymous
1

Answer:

Answer:

#include<stdio.h>

int main ()

{

int max,i;

printf("Enter the number upto which the squares of even number and cubes of odd number to be printed:");

scanf("%d",&max);

for(i=1;i<=max;i++)

{

if(i%2==0)

printf("%d ",i*i);

else

printf("%d ",i*i*i);

}

}

Hope you understand the code.

Similar questions