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 a function method?give example?

1908


what are non standard function in c

1420


In C programming, how do you insert quote characters (‘ and “) into the output screen?

878


What is difference between class and structure?

560


What is structure packing in c?

596






What is hashing in c?

630


What is extern c used for?

561


How can I get back to the interactive keyboard if stdin is redirected?

660


swap 2 numbers without using third variable?

652


What is the difference between int main and void main?

563


What is calloc in c?

652


Why we write conio h in c?

549


Explain what are binary trees?

601


Are global variables static in c?

662


What are the uses of a pointer?

669