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 / 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 |
what is advantages and disadvantages of CAT5,CAT5e,CAT6,CAT7,COAXIAL CABLE,FIBER-OPTIC
2 Answers ECR, Sun Hai Engineering, TCS,
A rectangular beam section of 300 mm width and 500 mm effective depth is reinforced with 4 bars of 20 mm diameter, what shear reinforcement is required to resist 200 kN shear (use working stress method)?
how to create session in visual web jsf page as we create in jsp and how to maintain that jsf session in another jsp page? <JSF=java server faces> <JSP=java server pages>
What is W-model in Software Engineering?
how to cable size by Amp with example
describe what is const pointer and why do we need it?
What are the duties of QA/QC Coordinator
what does the interviewer mean by saying "have a good life " cheerfully at the end of an HR interview??? is this positive or negative sign to be selected?
Explain work?
Can you get the name of the data file used as Infile in the control file used for sql loader, and store it in a column of a table if the name of the data files are in a particular fashion and it is getting picked up one by one for loading the data using the command "Infile *"
What is the fallacy in the following program segment ? int *f1() { int a=5; return &a; } f() int *b=f1() int c=*b; }
please explane me clusterd and non clusterd
Civil Engineering (5086)
Mechanical Engineering (4456)
Electrical Engineering (16639)
Electronics Communications (3918)
Chemical Engineering (1095)
Aeronautical Engineering (239)
Bio Engineering (96)
Metallurgy (361)
Industrial Engineering (259)
Instrumentation (3014)
Automobile Engineering (332)
Mechatronics Engineering (97)
Marine Engineering (124)
Power Plant Engineering (172)
Textile Engineering (575)
Production Engineering (25)
Satellite Systems Engineering (106)
Engineering AllOther (1379)