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...

plz answer.. a program that takes a string e.g. "345" and
returns integer 345

Answer Posted / vignesh1988i

#include<stdio.h>
#include<conio.h>
#include<string.h>
int fun(char *,int);
void main()
{
long int c,l;
char a1[20];
printf("enter the numerical string :");
scanf("%s",&a1);
l=strlen(a1);
c=fun(a,l);
printf("\n%ld",l);
getch();
}
int fun(char *a,long int l1)
{
long int a1[]=
{1,10,100,1000,10000,100000,1000000,10000000,100000000},c;
int p=a1[l1-1],c=0;
for(int i=0;a[i]!='\0';i++)
{
y=((int)a[i])*p; /*TYPE CASTING*/
c=c+y;
p=p/10;
}
return c;
}

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between volatile and const volatile?

935


Do you know the purpose of 'register' keyword?

964


What is the difference between char array and char pointer?

979


Explain the use of fflush() function?

1024


List the different types of c tokens?

1007


How many types of functions are there in c?

1055


What is indirection?

1022


What is a pointer variable in c language?

1036


What is 'bus error'?

1085


How to write c functions that modify head pointer of a linked list?

934


What are the differences between new and malloc in C?

1068


What is c token?

1008


Differentiate between #include<...> and #include '...'

1002


What is difference between union All statement and Union?

1055


Which control loop is recommended if you have to execute set of statements for fixed number of times?

1297