Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Simplify the program segment if X = B then C &#8592; true else C &#8592; false

0 Answers  


How can I make sure that my program is the only one accessing a file?

0 Answers  


what is the use of pointers

6 Answers   Adobe, GrapeCity,


How old is c programming language?

0 Answers  


What are static functions?

1 Answers  


HOW TO FIND OUT THE RREVERS OF A GIVEN DIGIT NUMBER IF IT IS INPUT THROUGH THE KEYBORD BY USING C LANGUAGE

3 Answers   Wipro,


in a town the percentage of men is 52 the percentage of total literacy is 48 if total percentage of literate men is 35 of the total population write a program to find the total no of the literate men and women if the population of the town is 80000

3 Answers  


how to implement stack work as a queue?

2 Answers  


Is there anything like an ifdef for typedefs?

0 Answers  


what is the difference between arrays and linked list

26 Answers   MAHINDRA, Tech Mahindra, Wipro,


Write a program to show the workingof auto variable.

2 Answers   Infotech,


how to print value of e(exp1)up to required no of digits after decimal?

1 Answers  


Categories