Decision Table Testing Next Date C Program
next_date.txt
File size: 896 Bytes
File content type: text/plain
Category: Practical Files
Subject: Software Testing and Quality Assurance
#include <stdio.h>
#include <stdbool.h>
#define YEAR_MIN 1900
#define YEAR_MAX 2100
int month[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
bool isLeapYear(int y) {
return ((y % 400 == 0) || (y % 4 == 0 && y % 100 != 0));
}
bool isNotValid(int d, int m, int y) {
return (d <= 0 || d > month[m] || m < 0 || m > 12 || y < YEAR_MIN || y > YEAR_MAX);
}
void test(int d, int m, int y) {
int d1 = d, m1= m, y1 = y;
if(isLeapYear(y)) {
month[2] = 29;
} else {
month[2] = 28;
}
if(isNotValid(d,m,y)) {
printf("%d\t%d\t%d\t%s\n",d1,m1,y1,"Not a valid date");
} else {
d++;
if(d > month[m]) {
d = 1;
m++;
}
if(m > 12) {
m = 1;
y++;
}
printf("%d\t%d\t%d\t%d/%d/%d\n",d1,m1,y1,d,m,y);
}
}
int main(void) {
test(0,0,1899);
test(0,0,1900);
test(0,3,1899);
test(0,3,1900);
test(20,0,1899);
test(20,0,1900);
test(20,3,1899);
test(20,3,1900);
return 0;
}
STQA Decision Table in C Pogram
Last Updated: July 16, 2022
Related
Lab Manual of Physics
Category: Practical FilesJuly 17, 2022
SNT Unit 3
Category: NotesJuly 17, 2022
BBA Entrepreneurship Development Notes Unit 3
Category: NotesJuly 17, 2022
Information Security Unit 4 Notes PDF
Category: NotesJuly 16, 2022
Information Security Unit 3 Notes PDF
Category: NotesJuly 16, 2022
Paging and Cordless Systems Notes PDF
Category: NotesJuly 16, 2022
Reverse linked list C
Category: Practical FilesJuly 17, 2022
Data Mining Practical File Exp 1-7
Category: Practical FilesJuly 16, 2022
Applied Chemistry Solved Question Papers PDF
Category: Question PapersJuly 16, 2022
IPU Indian Economy Notes Unit 4
Category: NotesJuly 17, 2022