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
what does the interviewer mean by saying "have a good life " cheerfully at the end of an HR interview??? is this positive to be selected reply yes or no
what is the difference a zero argument constructor and a default constructor?
what is the formula/ ratio for hollow block? considering to a 40 kgs of portland cement.
why multiple inheritence concept is not supported in c#?
what are the differences between malloc() and calloc() in c language?
My system suddenly get off,when i try to power on then it does not work but when i open it and clean RAM and insert it again, it power on.but after some day same problem? please give the answer (i have also changed RAM it's new.)
to which generation of prog. languages does ai prog languages belong
Write a test case plan for a typical banking application which involves functionalities like Balance enquiry, deposit, fund transfer etc. Make your assumptions and mention the same in your answer sheet.
How does an aeroplane stay airborne and how can some aeroplanes fly upside down?
how to hack email id & passward
what are nanoemulsions and how are they prepared? i want a brief outline about nanoemulsions.. is anyone of you is having any literature, can you share that? also any an idea where i can get the information?
how configur net and vpn on cisco product
what is the diffeence between SQL and ORACLE?
what is the difference between physical address and logical address?
I need ECIL last year Question papers for COMPUTER SCIENCE ENGG. Please