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
Why is c faster?
What's the difference between constant char *p and char * constant p?
How many levels of pointers can you have?
What is declaration and definition in c?
why return type of main is not necessary in linux
What are the different types of control structures?
What is data structure in c language?
What is the difference between memcpy and memmove?
Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.
Explain how can I remove the trailing spaces from a string?
Write a program to know whether the input number is an armstrong number.
In c programming language, how many parameters can be passed to a function ?
Why we use void main in c?
How can I change the size of the dynamically allocated array?
What is the difference between c and python?