4) Write a program that takes a 5 digit number and
calculates 2 power
that number and prints it.
I did the following program and is this correct
Answer Posted / renu gaindar
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
void main()
{
int a[5],b[5],c[2],j[2],d[2];
int d,e,f,g,h,i,l,result;
char first[10], secont[10],third[10],forth[10],fifth
[10],x[20];
printf("\nEnter 5 digit number : ");
for(i=1,i<=5;i++)
{
scanf("%d",a[i]);
}
c=a[5]*a[5]; //multiplication of units place
d[1]=c[1]; //1st carry
e=c[0]; //First Digit
c=a[4]*a[4];
d[1]=c+d;
f=c[0];
c=(a[3]*a[3]);
d[1]=c+d;
g=c[0];
c=(a[2]*a[2]);
d[1]=c+d;
h=c[0];
c=(a[1]*a[1]);
d[1]=c+d;
l=c[0];
atoi(e,first,10);
atoi(f,second,10);
atoi(g,third,10);
atoi(h,forth,10);
atoi(l,fifth,10);
strcpy(x,first);
strcpy(x,second);
strcpy(x,third);
strcpy(x,forth);
strcpy(x,fifth);
result=atoi(x);
printf("%d",result);
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
WAP in Java to print the format A B A B C D E D E
how will u test the idoc
what is domain functional level in windows server 2003?
who is your role modal give in few sentances
how will u recieve idoc
write a c++ program to interchange two-integer number without using the third variable. use concept of constructor overloading.
please send me latest Aptitude Test paper
If any kind of accident happen without any information to any one .what kind of action we have to take
How will I MOve Comp-1 variable into next variable without using Move statement?
Differentiate y = sinx + cosx + tanx
what is far pointer?
what do you mean by a p-code?
Is printf(?%d?,p); valid?
what is polymorphism.
What is Symbian.?