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 && in c programming?
Write a program to print numbers from 1 to 100 without using loop in c?
List the difference between a "copy constructor" and a "assignment operator"?
What is a static variable in c?
what is the different bitween abap and abap-hr?
What does stand for?
how to make a scientific calculater ?
What is line in c preprocessor?
What are external variables in c?
Why n++ execute faster than n+1 ?
please send me the code for multiplying sparse matrix using c
What are integer variable, floating-point variable and character variable?
Why is c so important?
What is extern variable in c with example?
"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks