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

What are the advantages and disadvantages of c language?

0 Answers  


What is the difference between near, far and huge pointers?

0 Answers  


If the static variable is declared as global, will it be same as extern?

1 Answers   Samsung,


What is static identifier?

0 Answers   TCS,


Is a house a shell structure?

0 Answers  


how do u find out the number of 1's in the binary representation of a decimal number without converting it into binary(i mean without dividing by 2 and finding out the remainder)? three lines of c code s there it seems...can anyone help

5 Answers  


What is typedef struct in c?

0 Answers  


What are bit fields? What is their use?

2 Answers   Adobe,


What is structure of c program?

0 Answers  


how to add two numbers without using arithmetic operators?

4 Answers  


with out using main how to execute the program?

2 Answers  


Why the below program throughs error during compilation? #include<stdio.h> #include<conio.h> enum { ZERO, ONE, TWO, }; main() { printf("%d",&TWO); getch(); }

2 Answers  


Categories