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 typeof in c?
Implement bit Array in C.
Why do we use int main instead of void main in c?
disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit
What is auto keyword in c?
Explain what is the difference between functions getch() and getche()?
Why main is used in c?
Differentiate between calloc and malloc.
What is .obj file in c?
What would be an example of a structure analogous to structure c?
Explain what does the format %10.2 mean when included in a printf statement?
I just typed in this program, and it is acting strangely. Can you see anything wrong with it?
What does it mean when the linker says that _end is undefined?
shorting algorithmS
write a programming in c to find the sum of all elements in an array through function.