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

how will u recieve an std idoc from sendor->reciever

1474


Write a java program to print the subsets of a string

1944


I am having 5 nos. ceiling fans in my home. if i switch on all fan at full speed say 5 , so Will my meter reading be runing fast ? OR if I keep all fans on very low speed, say 1, so meter reading will runing slowly. or it does not make any difference whether low or high. reading will remain same?

1362


hey guys.... My name is Bandana Thakur.Im a cse(8th sem) student.i want to make my career in php language.i want to work with google,wipro,tcs,infosys.peoples tell me that the salary package of php developer is very less n these companies do not work in php language.please tell me what i do now? should i go with the php language or make my career in another language? pls reply me in my e-mail id bandana.thakur14at@gmail.com

1588


can any give an exact example about, resolving the sql errorcode -305

1446






could i know the selection pattern at hpcl, am an undergradute in chemical technology, but my sujects or course do not figure out antwhere on the lists.

1488


I am some what lagging in talking English but i love to do job as an software engineer what will i do to improve my communication skills? please give me answer..........

2495


please provide me the type of questions or question pattern of bally.

1504


is the used fire extinguisher fall under Hazardous waste material?

1419


a steel bar 1' inch square 6' long is to be used as a column.ends are free to rotate put may not be displaced.stress is limited to 30,000 PSI

1376


Can you connect Active Directory to other 3rd-party Directory Services? Name a few options.

1559


SQL How can make delete and insert in one query

1405


in which website , i can able to get the electrical basics.?????????????

1363


i cannot go to my computer to set up why?

1382


Write a program in ā€˜Cā€™ language that will perform the following operation on static stack. 1. push 2. pop 3. Display 4. Exit Create separate functions for each operation. The push() should accept one argument of structure type and will not return any thing. The pop() function will not receive any argument & return structure type value. The stack & top must be declare as external variable. Each element of stack will contain the following information Roll No, Std Name, Course. Use do-while loop & switch case for generating the above menu. The format of the output should is given below: S.No. Roll No. Student Name Course 1 cse01 Anil Singh B.Tech

1482