#include<stdio.h> #include<stdlib.h> void main() { int num; // Variable marks is of Char Type char marks[3] = "98"; printf("Please Enter Marks : "); scanf("%s",marks); num = atoi(marks); printf("\nMarks : %d",num); }
Output :
Please Enter Marks : 76 Marks : 76
Explanation :
- FOR More Details : [ Atoi Function ]
- Entered Number is in the form of “String“.
- Suppose Entered Number is 78 then Entered Number has Representation -
"76"
- This “76″ is unable to Perform Arithmetic Operation , so Our aim is To Convert String into Integer which can perform “Arithmetic Operations” Like Integer.
Convert "76" to 76
No comments:
Post a Comment