4) Write a program that takes a 5 digit number and
calculates 2 power
that number and prints it.
i have done maximum par but i m findind problem in the
commented area.
please help...
Answers were Sorted based on User's Feedback
Answer / renugaindar
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
void main()
{
int j,i,k,d=0,n=0,e=0,c=0,y=0,l=0,f=0,b
[10],result,w;
int a[10],r[10],x[10],m;
char first[10],second[10],third[10],forth[10],fifth
[10],sixth[10];
clrscr();
for(i=0;i<5;i++)
{
printf("\n\t\tEnter %d element : ",i+1);
scanf("%d",&a[i]);
}
for(i=4;i>=0;i--)
{
printf("\n\n\t\t");
for(j=4;j>=0;j--)
{
c=a[i]*a[j];
d=c+f;
e=d%10;
f=d/10;
b[j]=e;
printf("\n\t\t Value of %d in B %
d== %d",i,j,b[j]);
if(j==0)
{
itoa(f,second,10);
itoa(b[0],first,10);
itoa(b[1],third,10);
itoa(b[2],forth,10);
itoa(b[3],fifth,10);
itoa(b[4],sixth,10);
strcpy(x,second);
strcat(x,first);
strcat(x,third);
strcat(x,forth);
strcat(x,fifth);
strcat(x,sixth);
result=atoi(x);
printf("\n\t\tresult: %
s",x);
/* for(l=0;l<6;l++)
{
w=atoi(x[l]);
r[l]=w;
printf
("\n\t\tResult %d == %s --%d",i,x,r[l]);
}*/
}
}
n++;
}
for(k=n;k>=0;k--)
{
if(k==3)
{
itoa(r[k],third,10);
itoa(0,forth,10);
strcpy(y,third);
strcat(y,forth);
for(l=9;l<=0;l--)
{
m=atoi(x);
printf("\n\n\t\t adding 0
in %s",x);
}
}
n--;
}
getch();
}
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / roshni
the length of integer should be much larger to store the
power value
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / ansh
#include<stdio.h>
void main()
{
int a;
long int b=1;
scanf("%d",&a);
printf("%d\n",a);
b=b<<a;
printf("%lu",b);
getch();
}
Is This Answer Correct ? | 1 Yes | 5 No |
using for loop sum 2 number of any 4 digit number in c language
main() { int a; a=++100; printf("%d",a); getch(); }
Why #include is used in c language?
The code is::::: if(condition) Printf("Hello"); Else Printf("World"); What will be the condition in if in such a way that both Hello and world are printed in a single attempt?????? Single Attempt in the sense... It must first print "Hello" and it Must go to else part and print "World"..... No loops, Recursion are allowed........................
14 Answers HOV Services, IBM, Potty,
What are different types of variables in c?
the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset
Is it better to bitshift a value than to multiply by 2?
Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?
a direct address that identifies a location by means of its displacement from a base address or segment a) absolute address b) relative address c) relative mode d) absolute mode
How to declare pointer variables?
Is int a keyword in c?
How to reverse a linked list
1 Answers Aricent, Fidelity, IBM, TCS,