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


Please Help Members By Posting Answers For Below Questions

explain overloaded constrator © constractor

1666


What do you think determines a person's progress in a good company?

11410


plz send me how to overhauling of freon bitzer semi receprocal comprassors with available video

1446


how to use photoshop and some related websites?

1616


Hi dost here Alok Kumar please send question pattern for NIC at godinall.kumar1@gmail.com or alok.iitb07@gmail.com

1413






Explain i.d.e. for visual c++?

1649


i want to know details about SBI bank exam and date when to apply and what is the eligibility and the model papers related to it and various post available for Engineering in Information Technology.

1528


Hi friends..cud any help to get QC 9.2 trial..i tried with HP site but did'nt got it..please help me out

1663


gsm features

1381


sir, plz send me the question regarding DMS gr1 questions of previous year as my exam is on 27/09/08...thanking u in advance...

1793


Why is it that a single, all – encompassing metric cannot be developed for programme complexity or programme quality?

1523


hi,i just want to know the best institute to learn oracle in bangalore because i am doing my BE there?

1416


difference between a for loop and a while loop? what are its uses in c language?

1554


how to print a number in character(ex. 123= one twenty three)?

1499


Has anyone attended any interviews in IITs for the positions like Research Associates/Fellowships?

1417