Write c-code for 5+55+555+5555+55555+555555+5555555.
Output will be it's answer...

Answers were Sorted based on User's Feedback



Write c-code for 5+55+555+5555+55555+555555+5555555. Output will be it's answer.....

Answer / vinod

main()
{
long int f=0,ans=0;
for(int i=0;i<7;i++)
{
f=f*10+5;
ans+=f;
}
printf("%ld",ans);
}

Is This Answer Correct ?    46 Yes 12 No

Write c-code for 5+55+555+5555+55555+555555+5555555. Output will be it's answer.....

Answer / ashish

#include<stdio.h>
#include<math.h>
void main()
{ long int f=0,ans=0,i;
clrscr();
for(i=0;i<7;i++)
{
f=f*10+5;
ans+=f;
}
printf("%ld",ans);
getch();
}

Is This Answer Correct ?    19 Yes 8 No

Write c-code for 5+55+555+5555+55555+555555+5555555. Output will be it's answer.....

Answer / arjun

The actual answer is 6172835.But integer range is only -32768
to 32767.so the actual answer cannot be displayed.

Is This Answer Correct ?    24 Yes 15 No

Write c-code for 5+55+555+5555+55555+555555+5555555. Output will be it's answer.....

Answer / sunny

Hi Guys,

The answers above are correct but i was wondering if one has to add 5+55+555+.... till 'n'digits then??

Then the answer would be

#include<stdio.h>
#include<math.h>
void main()
{

long int res=0;
int n;
printf("The Maximum Digit(i.e. if youy want result upto 555 then enter '3'):");
scanf("%d",&n);

res= (5*pow(10,(n+1)) - 50 -(45*n))/81;
// VII standard maths
printf("%ld",res);
}


THANX

Is This Answer Correct ?    10 Yes 3 No

Post New Answer

More C Interview Questions

Differentiate between full, complete & perfect binary trees.

0 Answers  


what are you see during placement time in the student.

0 Answers   Goldman Sachs, TCS, Tech Solutions,


What are the different categories of functions in c?

0 Answers  


Explain what is the purpose of "extern" keyword in a function declaration?

0 Answers  


#include <stdio.h> int main ( int argc, char* argv [ ] ) { int value1 = 10; int value2 = 5; printf ( "\n The sum is :%d", value1 | value2 ); } This is the answer asked by some one to add two numbers with out using arithmetic operator?Yes this answer is write it given out put as 15.But how????? what is need of following line? int main ( int argc, char* argv [ ] ) how it work?what is the meaning for this line? please explain me.Advance thanks

9 Answers   Excel,






write a programming in c to find the sum of all elements in an array through function.

0 Answers  


What does nil mean in c?

0 Answers  


print the palindrome numbers in between 0 to n

1 Answers  


while running a program, i got the msg that press return key to exit.what that mean in C as there are no such options as far i know.

1 Answers   TCS,


What is the maximum no. of arguments that can be given in a command line in C.?

0 Answers   HCL,


What does the characters “r” and “w” mean when writing programs that will make use of files?

0 Answers  


FILE PROGRAMMING

0 Answers   Wipro,


Categories