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
Where are some collections of useful code fragments and examples?
What are the types of data files?
What is hashing in c?
Is main an identifier in c?
What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?
What is dynamic variable in c?
What is the right type to use for boolean values in c? Is there a standard type?
Find MAXIMUM of three distinct integers using a single C statement
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?
Linked list is a Linear or non linear explain if linear how it working as a non linear data structures
I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.
What do you mean by recursion in c?
What are the Advantages of using macro
What is c++ used for today?
difference between native and cross compilers