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
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
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
Physics,
2 months ago
English,
2 months ago
Computer Science,
2 months ago
Science,
4 months ago
Computer Science,
9 months ago
English,
9 months ago