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


Please Help Members By Posting Answers For Below Questions

where are auto variables stored? What are the characteristics of an auto variable?

597


How main function is called in c?

633


How do we open a binary file in Read/Write mode in C?

687


What are near, far and huge pointers?

650


What is a lookup table in c?

633






Can you please compare array with pointer?

623


Is c is a high level language?

626


List out few of the applications that make use of Multilinked Structures?

1315


c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above

620


What are logical errors and how does it differ from syntax errors?

667


a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list

635


4-Take two sets of 5 numbers from user in two arrays. Sort array 1 in ascending and array 2 in descending order. Perform sorting by passing array to a function mySort(array, sortingOrder). Then multiply both the arrays returned from function, using metric multiplication technique in main. Print result in metric format.

1731


Why do we use header files in c?

588


What are directives in c?

550


Explain union.

641