write a c program to find the square of a 5 digit number
and print the result.
Answer Posted / paras
#include<stdio.h>
#include<conio.h>
void main(){
clrscr();
long a=0,b=0;
long num;
printf("Enter a 5 digit number: ");
scanf("%ld",&num);
a=num/100;
b=num%100;
printf("Square of this number is: ");
long c=2*a*b;
a=a*a;
b=b*b;
long t=c%100;
t*=100;
t+=b;
long w=c/100;
w+=a;
if(t/10000 <= 0)
printf("%ld",w);
else
{
w=w+t/10000;
t=t%10000;
printf("%ld",w);
}
if(t/10==0)
printf("000%ld",t);
else if(t/100==0)
printf("00%ld",t);
else if(t/10==0)
printf("0%ld",t);
else
printf("%ld",t);
getch();
}
| Is This Answer Correct ? | 7 Yes | 7 No |
Post New Answer View All Answers
What is a stream?
Why do we use static in c?
Explain how can I convert a string to a number?
What is an array in c?
Explain how can I write functions that take a variable number of arguments?
What is gets() function?
What is a pointer value and address in c?
Explain how do you declare an array that will hold more than 64kb of data?
Is javascript based on c?
How can I insert or delete a line (or record) in the middle of a file?
What is pointer to pointer in c?
Explain what is the benefit of using #define to declare a constant?
Is there any demerits of using pointer?
I need a sort of an approximate strcmp routine?
What are the valid places to have keyword “break”?