Squared


This is a companion discussion topic for the original entry at https://toph.co/p/squared

my outcome is right but why does the test in toph say wrong answer

#include<stdio.h>
int main()
{
    float side,area;
    scanf("%f",&side);
    area=side * side;
    printf("%f",area);
    return 0;

}

@AG_Ohe11 Try using int instead of float.

@AG_Ohe11 kire ohe naki?

i tested this program and it also work then why here its saying compilation wrong…

#include <stdio.h>
#include<math.h>

int main()
{
    int side,area;
    scanf("%d",&side);
    area=side*side;
    printf("%d",area);

    return 0;
}

There is no problem with your code. The compiler compiled it successfully. So it’s not possible to get Compilation Error.

@hjr265
বাংলা স্টেটমেন্ট এ ক্ষেত্রফল না লিখে আয়তন লিখা।

2 Likes

// you have to input integer and output integer…
#include<stdio.h>
#include<math.h>
int main()
{
int a;
scanf("%d",&a);
printf("%d",(int) pow(a,2) );
return 0;
}

//you can write a program like it though it’s so difficult for beginners…

#include<stdio.h>
int main()
{
int length,area;
area =length*length;
scanf("%d",&length);
printf("%d\n",area);
}
what is the problem with this code?

L = input(int())
sum = L ** 2
print (sum)

what is the problem