plz answer.. a program that takes a string e.g. "345" and
returns integer 345
Answer Posted / vadivel t
The equalent code to atoi() library fuction which i hav
written, below.
#include<stdio.h>
#include<conio.h>
int MyAtoi(char *cptr);
main()
{
char *cptr = "123445";
printf("INTEGER EQU IS: %d\n", MyAtoi(cptr));
getch();
}
int MyAtoi(char *cptr)
{
int iptr = 0;
while((*cptr != '\0') && ((*cptr >= 48 && *cptr <= 57) ||
(*cptr == 32)))
{
if(*cptr != ' ')
iptr = (iptr * 10) + (*cptr - 48);
cptr++;
}
return iptr;
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
State two uses of pointers in C?
what are the advanced features of functions a) function declaration and prototypes b) calling functions by value or by reference c) recursion d) all the above
4-Take two sets of 5 numbers from user in two arrays. Sort array 1 in ascending and array 2 in descending order. Perform sorting by passing array to a function mySort(array, sortingOrder). Then multiply both the arrays returned from function, using metric multiplication technique in main. Print result in metric format.
Explain built-in function?
Can the sizeof operator be used to tell the size of an array passed to a function?
What is stack in c?
Explain what is #line used for?
What is void main () in c?
What is switch in c?
How many header files are in c?
how to capitalise first letter of each word in a given string?
How do we print only part of a string in c?
What is the difference between c and python?
write a program to generate address labels using structures?
we called a function and passed something do it we have always passed the "values" of variables to the called function. such functions calles are called a) calls by reference b) calls by value c) calls by zero d) none of the above