Write a c++ program that asks from user to input date without slashes and you are supposed to insert slashes into it
Sample Input:
20 21 2022
Sample Output
20/21/2022
#include <iostream>
#include <cstring>
using namespace std;
int main(){
char date[20];
cin.getline(date, 20);
for (int i = 0; i < strlen(date); i++)
{
if (date[i] == ' ')
{
date[i] = '/';
}
}
cout << date;
return 0;
}
cpp programming exercise with solution |