-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task-1
65 lines (59 loc) · 1.7 KB
/
Task-1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include<iostream>
#include<windows.h>
using namespace std;
void print_tasks(string tasks[], int task_count){
cout<<"Tasks TO DO:"<<endl;
cout<<"------------------------------------"<<endl;
for(int i=0; i<task_count; i++){
cout<<"Tasks"<<i<<":"<<tasks[i]<<endl;
}
cout<<"------------------------------------"<<endl;
}
int main(){
string tasks[10]={""};
int task_count=0;
int option =-1;
while(option != 0){
cout<<"----TO DO LIST----"<<endl;
cout<<"1- To Add New Task:"<<endl;
cout<<"2= To View Tasks:"<<endl;
cout<<"3- Delete The Tasks:"<<endl;
cout<<"0- Terminate the programm"<<endl;
cin>>option;
switch(option)
{
case 1:
{
if(task_count > 9){
cout<<"'''Task List Is Full'''"<<endl;
}
else{
cout<<"Enter A New Task:";
cin.ignore();
getline(cin,tasks[task_count]);
task_count++;
}
break;
}
case 2:
print_tasks(tasks,task_count);
break;
case 3:
{
int del_tasks=0;
cout<<"Enter A Task TO Delete:"<<endl;
cin>>del_tasks;
if(del_tasks<0 || del_tasks>9){
cout<<"You entered wrong task no."<<endl;
break;
}
for(int i= del_tasks; i<task_count; i++){
tasks[i]=tasks[i+1];
}
task_count=task_count-1;
break;
}
}
}
return 0;
}