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
What is wild pointer in c?
How do we make a global variable accessible across files? Explain the extern keyword?
Why c is called a middle level language?
What are categories used for in c?
What is memory leak in c?
How to write a code for reverse of string without using string functions?
Can we add pointers together?
#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }
Why double pointer is used in c?
What is the data segment that is followed by c?
What is an auto keyword in c?
Write a program to check whether a number is prime or not using c?
Explain what is the difference between #include and #include 'file' ?
GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)
What is a macro?