Computer Science, asked by amardeep23, 1 year ago

how will you format date so that dates appear in a format similar to 26-January-2022

please answer fast​

Answers

Answered by sweety2021
13

Answer:

the format will look like this

DD-MM-YYYY

Answered by dreamrob
6

#include<iostream>

#include <stdio.h>

#include <stdlib.h>

#include<string.h>

using namespace std;

int main()

{

char date[11];

int dd,mm,yyyy;

cout<<"Enter date : dd/mm/yyyy : ";

cin>>date;

if(strlen(date)!=10)

{

 cout<<"Error:Input should be in dd/mm/yyyy format";

}

else

{

 char d[3],m[3],y[5];

 int i,j;

 

 for(i=0;i<2;i++)

 {

  d[i]=date[i];  

 }

 

 for(i=3,j=0;i<5;i++,j++)

 {

  m[j]=date[i];

 }

 for(i = 6, j=0; i<10; i++, j++)

 {

  y[j]=date[i];

 }

 dd=atoi(d);

 mm=atoi(m);

 yyyy=atoi(y);

}

string months[13] = {"","January","February","March","April","May","June","July","August","September","October","November","December"};

cout<<dd<<"-"<<months[mm]<<"-"<<yyyy;

return 0;

}

Similar questions