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
Write a program to check palindrome number in c programming?
What is the use of printf() and scanf() functions?
What is a program flowchart?
What is the c language function prototype?
Can the sizeof operator be used to tell the size of an array passed to a function?
Is it possible to have a function as a parameter in another function?
what is use of malloc and calloc?
Array is an lvalue or not?
What does static variable mean in c?
What is function prototype?
Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?
What is quick sort in c?
What is difference between structure and union in c programming?
What is dynamic memory allocation?
why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???