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
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.
what is polymorphism.
what are the simlerities between macro and subroutine
In HSE what is Lost time accident? why it is to be reported within 48 hrs to gov.authorities ?
what is dns?
Draw the diagram showing the function stack, illustrating the variables that were pushed on the stack at the point when function f2 has been introduced . type def struct { double x,double y} point; } main( int argc, char *arg[3]) { double a; int b,c; f1(a,b); } f1(double x, int y) {point p; stack int n; f2(p,x,y) } f2(point p, double angle) { int i,j,k,int max;
am a textile eng. frombut with major of my course including chemical eng, subjects, can i too apply to the co.?
What are the input documents to 1.Functional testing,2.System testing and 3.Integration testing. Whether there will be separate test cases for regression testing or functional testing?
program for inter process communicatin using message sharing in unix c
can i get some win vista notes
Write steps of retrieving data using ado.net?
int main() { int d = 10; int m = 2; int y = 3603; int c = 0; int val; val = ( d + m + y + (y/4) + c) % 7; cout << val; return 0; }
what is the difference between physical address and logical address?
what is test strategy
a book consists of chapter ,chapter consist of sections and sections consists of subsections.construct a tree and print the node.