Saturday, November 23, 2019

Write a C program to convert a string to a long integer

#include<stdio.h>
int main()

{

  long longinteger;

  int no;
 
  // string to long integer converison
  longinteger = atol("56789");

  // string to integer converison
  no=atoi("345");


  printf("The string converted to long int is %ld\n", longinteger-2);

  printf("The string converted to int is %d\n", no+2);


  return 0;

 }

}

OUTPUT:
The string converted to long int is 56787
The string converted to int is 347

No comments:

Post a Comment