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
Is null a keyword in c?
What is || operator and how does it function in a program?
Is null always defined as 0(zero)?
Do you know the difference between malloc() and calloc() function?
5 Write an Algorithm to find the maximum and minimum items in a set of ānā element.
Explain what are compound statements?
What does do in c?
What is clrscr in c?
What do header files do?
write a c program to print the next of a particular no without using the arithmetic operator or looping statements?
write a program to copy the string using switch case?
What is the purpose of realloc()?
Write a program to implement queue.
What is an expression?
What is volatile variable in c with example?