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
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
Write a program in c to replace any vowel in a string with z?
Explain about C function prototype?
Explain the difference between the local variable and global variable in c?
.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }
What is meant by high-order and low-order bytes?
Is c is a procedural language?
GIVEN A FLOATING POINT NUMBER HOW IS IT ACTUALLY STORED IN MEMORY ? CAN ANYONE EXPLAIN?? THE 32 BIT REPRESENTATION OF A FLOATING POINT NUMBER ALLOTS: 1 BIT-SIGN 8 BITS-EXPONENT 23 BITS-MANTISSA
in multiple branching construct "default" case is a) optional b) compulsarily c) it is not include in this construct d) none of the above
What is the difference between void main and main in c?
What is the c value paradox and how is it explained?
How do you declare a variable that will hold string values?
Can main () be called recursively?
When should a type cast be used?
Explain enumerated types in c language?