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 a volatile keyword in c?
What is the difference between malloc calloc and realloc in c?
What are the different types of pointers used in c language?
What is a far pointer in c?
What are dangling pointers in c?
What do you understand by friend-functions? How are they used?
What's the difference between constant char *p and char * constant p?
Explain the bubble sort algorithm.
What is a stream in c programming?
a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above
to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?
Why header file is used in c?
Is c++ based on c?
Which is more efficient, a switch statement or an if else chain?
Explain what is the difference between #include and #include 'file' ?