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
explain overloaded constrator © constractor
What do you think determines a person's progress in a good company?
plz send me how to overhauling of freon bitzer semi receprocal comprassors with available video
how to use photoshop and some related websites?
Hi dost here Alok Kumar please send question pattern for NIC at godinall.kumar1@gmail.com or alok.iitb07@gmail.com
Explain i.d.e. for visual c++?
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.
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
gsm features
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...
Why is it that a single, all – encompassing metric cannot be developed for programme complexity or programme quality?
hi,i just want to know the best institute to learn oracle in bangalore because i am doing my BE there?
difference between a for loop and a while loop? what are its uses in c language?
how to print a number in character(ex. 123= one twenty three)?
Has anyone attended any interviews in IITs for the positions like Research Associates/Fellowships?