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 auto variables stored? What are the characteristics of an auto variable?
How main function is called in c?
How do we open a binary file in Read/Write mode in C?
What are near, far and huge pointers?
What is a lookup table in c?
Can you please compare array with pointer?
Is c is a high level language?
List out few of the applications that make use of Multilinked Structures?
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
What are logical errors and how does it differ from syntax errors?
a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list
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.
Why do we use header files in c?
What are directives in c?
Explain union.