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



4) Write a program that takes a 5 digit number and calculates 2 power that number and prints it. ..

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

Post New Answer

More Engineering AllOther Interview Questions

what is overflow and what are the conditions for which overflow possible?

0 Answers  


Hi I need exam pattern for ECIL Computer/IT category...

1 Answers  


what is difference between shell commands and shell scripting commands or both r same?

0 Answers  


10. Each alphabet stands for one digit in the following multiplication. T H I S x I S --------- X F X X X X U X ------------ X X N X X ------------ What is the maximum value T can take?

4 Answers   eLitmus, Infosys, Verchaska,


reverse a number ( like 1234 into 4321) using malloc in C programming

0 Answers   TCY Online,






what is the quantity of cement and sand in 1 sq.m (mortar ratio ) a, 1:4 b, 1:3 c, 1:6

0 Answers  


What is the meaning of "co relation" and what is the value of "co relation" in the performance testing environment.

0 Answers  


what are differences b/w EIA 449 and EIA 530?

0 Answers  


can u tell me what are the subjects involved in group I and II and how i prepare for the exam

0 Answers  


Sir, I was recently placed at ITC Infotect. My ctc is 2.46lpa. How much will I get in hand every month? Plssss answer. Thanx in advance.

0 Answers   ITC Infotech,


DVC2000 performent: travel ??? and not output signal

0 Answers  


today apptitude questions

0 Answers  


Categories
  • Civil Engineering Interview Questions Civil Engineering (5084)
  • Mechanical Engineering Interview Questions Mechanical Engineering (4451)
  • Electrical Engineering Interview Questions Electrical Engineering (16631)
  • Electronics Communications Interview Questions Electronics Communications (3918)
  • Chemical Engineering Interview Questions Chemical Engineering (1094)
  • Aeronautical Engineering Interview Questions Aeronautical Engineering (239)
  • Bio Engineering Interview Questions Bio Engineering (96)
  • Metallurgy Interview Questions Metallurgy (361)
  • Industrial Engineering Interview Questions Industrial Engineering (259)
  • Instrumentation Interview Questions Instrumentation (3014)
  • Automobile Engineering Interview Questions Automobile Engineering (332)
  • Mechatronics Engineering Interview Questions Mechatronics Engineering (97)
  • Marine Engineering Interview Questions Marine Engineering (124)
  • Power Plant Engineering Interview Questions Power Plant Engineering (172)
  • Textile Engineering Interview Questions Textile Engineering (575)
  • Production Engineering Interview Questions Production Engineering (25)
  • Satellite Systems Engineering Interview Questions Satellite Systems Engineering (106)
  • Engineering AllOther Interview Questions Engineering AllOther (1379)