Wednesday, April 9, 2014

Show the numeric values entered in a character array

This program is used to show numeric values entered in a character array but the numeric values should be entered before the characters.



#include <iostream>
#include <conio.h>
#include <stdlib.h>

void main()
{
char arr[5];  //Creating a character array of size 5
cout<<"Enter the values of the array\n"; //Displaying a message asking to enter values
cin>>arr;  //taking input from the user and storing it in the character array
cout<<endl <<atoi(arr)<<endl<<"Program ends\n";  /*using built in function "atoi" and using it to convert numeric values
entered in a character array and converting into integer*/
getch();
}
 
Here's how the output will look like
 
 

Widgets

 

Copyright @ 2014 CPP Fuzz.