SlideShare a Scribd company logo
#include
int main() {
char file_name[20], guess[6];
char Life[15][15];
int ctr=0, ctr2=0;
char *g;
FILE *fp1;
int i, j;
int neighbors;
printf ("Enter file_name of initial generation: ");
scanf ("%s", file_name);
fp1 = fopen(file_name, "r");
do {
g = fgets (guess, 6, fp1);
for(ctr2=0;ctr2<6;ctr2++){
Life[ctr][ctr2]=g[ctr2];
}
ctr++;
if (g!=NULL)
printf ("%s", guess);
}
while (g != NULL);
fclose (fp1);
printf (" ");
neighbors=0;
for (i=0; i<4; i++) {
for (j=0; j<4; j++) {
if (i==0 && j==0) {
if (Life [i+1][j]=='X')
neighbors ++;
if (Life [i][j+1]=='X')
neighbors ++;
if (Life [i+1][j+1]=='X')
neighbors ++;
}
if (i==3 && j==0) {
if (Life [i-1][j]=='X')
neighbors ++;
if (Life [i-1][j+1]=='X')
neighbors ++;
if (Life [i][j+1]=='X')
neighbors ++;
}
if (i==0 && j==3) {
if (Life [i][j-1]=='X')
neighbors ++;
if (Life [i+1][j-1]=='X')
neighbors ++;
if (Life [i+1][j]=='X')
neighbors ++;
}
if (i==3 && j==3) {
if (Life [i][j-1]=='X')
neighbors ++;
if (Life [i-1][j-1]=='X')
neighbors ++;
if (Life [i-1][j]=='X')
neighbors ++;
}
if (j==0 && i!=0 && i!=3) {
if (Life [i-1][j]=='X')
neighbors ++;
if (Life [i-1][j+1]=='X')
neighbors ++;
if (Life [i][j+1]=='X')
neighbors ++;
if (Life [i+1][j]=='X')
neighbors ++;
if (Life [i+1][j+1]=='X')
neighbors ++;
}
if (j==3 && i!=0 && i!=3) {
if (Life [i-1][j]=='X')
neighbors ++;
if (Life [i-1][j-1]=='X')
neighbors ++;
if (Life [i][j-1]=='X')
neighbors ++;
if (Life [i+1][j-1]=='X')
neighbors ++;
if (Life [i+1][j+1]=='X')
neighbors ++;
}
if (i==0 && j!=0 && j!=3) {
if (Life [i][j-1]=='X')
neighbors ++;
if (Life [i][j+1]=='X')
neighbors ++;
if (Life [i+1][j-1]=='X')
neighbors ++;
if (Life [i+1][j]=='X')
neighbors ++;
if (Life [i+1][j+1]=='X')
neighbors ++;
}
if (i==3 && j!=0 && j!=3) {
if (Life [i][j-1]=='X')
neighbors ++;
if (Life [i][j+1]=='X')
neighbors ++;
if (Life [i-1][j-1]=='X')
neighbors ++;
if (Life [i-1][j]=='X')
neighbors ++;
if (Life [i-1][j+1]=='X')
neighbors ++;
}
if (i!=0 && i!=3 && j!=0 && j!=3) {
if (Life [i][j+1]=='X')
neighbors ++;
if (Life [i][j-1]=='X')
neighbors ++;
if (Life [i-1][j]=='X')
neighbors ++;
if (Life [i-1][j+1]=='X')
neighbors ++;
if (Life [i-1][j-1]=='X')
neighbors ++;
if (Life [i+1][j]=='X')
neighbors ++;
if (Life [i+1][j+1]=='X')
neighbors ++;
if (Life [i+1][j-1]=='X')
} neighbors ++;
}
}
for (i=0; i<4; i++) {
for (j=0; j<4; j++) {
if (Life [i][j]==' ') {
if (neighbors==3)
Life [i][j]='X';
else
Life [i][j]=' ';
}
if (Life [i][j]=='X') {
if (neighbors==2 && neighbors==3)
Life [i][j]='X';
else
Life [i][j]=' ';
}
}
}
printf ("The new generation is: ");
printf ("%s", Life[i][j]);
return 0;
}
Solution
#include
int main() {
char file_name[20], guess[6];
char Life[15][15];
int ctr=0, ctr2=0;
char *g;
FILE *fp1;
int i, j;
int neighbors;
printf ("Enter file_name of initial generation: ");
scanf ("%s", file_name);
fp1 = fopen(file_name, "r");
do {
g = fgets (guess, 6, fp1);
for(ctr2=0;ctr2<6;ctr2++){
Life[ctr][ctr2]=g[ctr2];
}
ctr++;
if (g!=NULL)
printf ("%s", guess);
}
while (g != NULL);
fclose (fp1);
printf (" ");
neighbors=0;
for (i=0; i<4; i++) {
for (j=0; j<4; j++) {
if (i==0 && j==0) {
if (Life [i+1][j]=='X')
neighbors ++;
if (Life [i][j+1]=='X')
neighbors ++;
if (Life [i+1][j+1]=='X')
neighbors ++;
}
if (i==3 && j==0) {
if (Life [i-1][j]=='X')
neighbors ++;
if (Life [i-1][j+1]=='X')
neighbors ++;
if (Life [i][j+1]=='X')
neighbors ++;
}
if (i==0 && j==3) {
if (Life [i][j-1]=='X')
neighbors ++;
if (Life [i+1][j-1]=='X')
neighbors ++;
if (Life [i+1][j]=='X')
neighbors ++;
}
if (i==3 && j==3) {
if (Life [i][j-1]=='X')
neighbors ++;
if (Life [i-1][j-1]=='X')
neighbors ++;
if (Life [i-1][j]=='X')
neighbors ++;
}
if (j==0 && i!=0 && i!=3) {
if (Life [i-1][j]=='X')
neighbors ++;
if (Life [i-1][j+1]=='X')
neighbors ++;
if (Life [i][j+1]=='X')
neighbors ++;
if (Life [i+1][j]=='X')
neighbors ++;
if (Life [i+1][j+1]=='X')
neighbors ++;
}
if (j==3 && i!=0 && i!=3) {
if (Life [i-1][j]=='X')
neighbors ++;
if (Life [i-1][j-1]=='X')
neighbors ++;
if (Life [i][j-1]=='X')
neighbors ++;
if (Life [i+1][j-1]=='X')
neighbors ++;
if (Life [i+1][j+1]=='X')
neighbors ++;
}
if (i==0 && j!=0 && j!=3) {
if (Life [i][j-1]=='X')
neighbors ++;
if (Life [i][j+1]=='X')
neighbors ++;
if (Life [i+1][j-1]=='X')
neighbors ++;
if (Life [i+1][j]=='X')
neighbors ++;
if (Life [i+1][j+1]=='X')
neighbors ++;
}
if (i==3 && j!=0 && j!=3) {
if (Life [i][j-1]=='X')
neighbors ++;
if (Life [i][j+1]=='X')
neighbors ++;
if (Life [i-1][j-1]=='X')
neighbors ++;
if (Life [i-1][j]=='X')
neighbors ++;
if (Life [i-1][j+1]=='X')
neighbors ++;
}
if (i!=0 && i!=3 && j!=0 && j!=3) {
if (Life [i][j+1]=='X')
neighbors ++;
if (Life [i][j-1]=='X')
neighbors ++;
if (Life [i-1][j]=='X')
neighbors ++;
if (Life [i-1][j+1]=='X')
neighbors ++;
if (Life [i-1][j-1]=='X')
neighbors ++;
if (Life [i+1][j]=='X')
neighbors ++;
if (Life [i+1][j+1]=='X')
neighbors ++;
if (Life [i+1][j-1]=='X')
} neighbors ++;
}
}
for (i=0; i<4; i++) {
for (j=0; j<4; j++) {
if (Life [i][j]==' ') {
if (neighbors==3)
Life [i][j]='X';
else
Life [i][j]=' ';
}
if (Life [i][j]=='X') {
if (neighbors==2 && neighbors==3)
Life [i][j]='X';
else
Life [i][j]=' ';
}
}
}
printf ("The new generation is: ");
printf ("%s", Life[i][j]);
return 0;
}

More Related Content

Similar to     #include STDIO.H     int main() {        char file_name[.pdf

Code em Poker
Code em PokerCode em Poker
Code em Poker
Ankit Gupta
 
AI For Texam Hold'em poker
AI For Texam Hold'em pokerAI For Texam Hold'em poker
AI For Texam Hold'em poker
मलय केशव
 
Network lab manual
Network lab manualNetwork lab manual
Network lab manual
Prabhu D
 
Blocks+gcd入門
Blocks+gcd入門Blocks+gcd入門
Blocks+gcd入門
領一 和泉田
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdf
anujmkt
 
Add a 3rd field help that contains a short help string for each of t.pdf
Add a 3rd field help that contains a short help string for each of t.pdfAdd a 3rd field help that contains a short help string for each of t.pdf
Add a 3rd field help that contains a short help string for each of t.pdf
info245627
 
Data structures
Data structuresData structures
Data structures
gayatrigayu1
 
Burrowing through go! the book
Burrowing through go! the bookBurrowing through go! the book
Burrowing through go! the book
Vishal Ghadge
 
Sorting programs
Sorting programsSorting programs
Sorting programs
Varun Garg
 
Bai Giang 11
Bai Giang 11Bai Giang 11
Bai Giang 11
nbb3i
 
Cquestions
Cquestions Cquestions
Cquestions
mohamed sikander
 
C programs Set 4
C programs Set 4C programs Set 4
C programs Set 4
Koshy Geoji
 
Lab Question
Lab QuestionLab Question
C program
C programC program
C program
Komal Singh
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
Rahul Chugh
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacion
Jeff Tu Pechito
 
programs
programsprograms
programs
Vishnu V
 
งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์
น้ำตาล มาแล้วจ้า
 
Clock For My
Clock For MyClock For My
Clock For My
shamalanamnam
 
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docxcmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
gordienaysmythe
 

Similar to     #include STDIO.H     int main() {        char file_name[.pdf (20)

Code em Poker
Code em PokerCode em Poker
Code em Poker
 
AI For Texam Hold'em poker
AI For Texam Hold'em pokerAI For Texam Hold'em poker
AI For Texam Hold'em poker
 
Network lab manual
Network lab manualNetwork lab manual
Network lab manual
 
Blocks+gcd入門
Blocks+gcd入門Blocks+gcd入門
Blocks+gcd入門
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdf
 
Add a 3rd field help that contains a short help string for each of t.pdf
Add a 3rd field help that contains a short help string for each of t.pdfAdd a 3rd field help that contains a short help string for each of t.pdf
Add a 3rd field help that contains a short help string for each of t.pdf
 
Data structures
Data structuresData structures
Data structures
 
Burrowing through go! the book
Burrowing through go! the bookBurrowing through go! the book
Burrowing through go! the book
 
Sorting programs
Sorting programsSorting programs
Sorting programs
 
Bai Giang 11
Bai Giang 11Bai Giang 11
Bai Giang 11
 
Cquestions
Cquestions Cquestions
Cquestions
 
C programs Set 4
C programs Set 4C programs Set 4
C programs Set 4
 
Lab Question
Lab QuestionLab Question
Lab Question
 
C program
C programC program
C program
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacion
 
programs
programsprograms
programs
 
งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์
 
Clock For My
Clock For MyClock For My
Clock For My
 
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docxcmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
 

More from anjalipub

when substance dissolves consider following two c.pdf
                     when substance dissolves consider following two c.pdf                     when substance dissolves consider following two c.pdf
when substance dissolves consider following two c.pdf
anjalipub
 
Molarity = molevolume(L) moles of HONH2 = 0.500.pdf
                     Molarity = molevolume(L) moles of HONH2 = 0.500.pdf                     Molarity = molevolume(L) moles of HONH2 = 0.500.pdf
Molarity = molevolume(L) moles of HONH2 = 0.500.pdf
anjalipub
 
l=1 means p-orbital which is havind domble shape .pdf
                     l=1 means p-orbital which is havind domble shape .pdf                     l=1 means p-orbital which is havind domble shape .pdf
l=1 means p-orbital which is havind domble shape .pdf
anjalipub
 
It will be due to A because it has a shorter life.pdf
                     It will be due to A because it has a shorter life.pdf                     It will be due to A because it has a shorter life.pdf
It will be due to A because it has a shorter life.pdf
anjalipub
 
isolated .pdf
                     isolated                                      .pdf                     isolated                                      .pdf
isolated .pdf
anjalipub
 
d) inconsistent with the general trend relating c.pdf
                     d) inconsistent with the general trend relating c.pdf                     d) inconsistent with the general trend relating c.pdf
d) inconsistent with the general trend relating c.pdf
anjalipub
 
The yellowbrown coloration is due to the fomation of the triiodide .pdf
The yellowbrown coloration is due to the fomation of the triiodide .pdfThe yellowbrown coloration is due to the fomation of the triiodide .pdf
The yellowbrown coloration is due to the fomation of the triiodide .pdf
anjalipub
 
SolutionCu2+ and CO2, BOTH will behave as a Lewis acid toward OH-.pdf
SolutionCu2+ and CO2, BOTH will behave as a Lewis acid toward OH-.pdfSolutionCu2+ and CO2, BOTH will behave as a Lewis acid toward OH-.pdf
SolutionCu2+ and CO2, BOTH will behave as a Lewis acid toward OH-.pdf
anjalipub
 
TCP provide reliable connection oriented transport of a byte brook U.pdf
TCP provide reliable connection oriented transport of a byte brook U.pdfTCP provide reliable connection oriented transport of a byte brook U.pdf
TCP provide reliable connection oriented transport of a byte brook U.pdf
anjalipub
 
Solution - (E) Calculation of WACC (Weighted average cost of capital.pdf
Solution - (E) Calculation of WACC (Weighted average cost of capital.pdfSolution - (E) Calculation of WACC (Weighted average cost of capital.pdf
Solution - (E) Calculation of WACC (Weighted average cost of capital.pdf
anjalipub
 
Solution           His total Volume          = the volume of wa.pdf
Solution           His total Volume          = the volume of wa.pdfSolution           His total Volume          = the volume of wa.pdf
Solution           His total Volume          = the volume of wa.pdf
anjalipub
 
SQLiteStudio is a SQLite database manager with the following feature.pdf
SQLiteStudio is a SQLite database manager with the following feature.pdfSQLiteStudio is a SQLite database manager with the following feature.pdf
SQLiteStudio is a SQLite database manager with the following feature.pdf
anjalipub
 
C) H2O .pdf
                     C) H2O                                       .pdf                     C) H2O                                       .pdf
C) H2O .pdf
anjalipub
 
Salvia apiana (white sage, bee sage, or sacred sage) is an evergreen.pdf
Salvia apiana (white sage, bee sage, or sacred sage) is an evergreen.pdfSalvia apiana (white sage, bee sage, or sacred sage) is an evergreen.pdf
Salvia apiana (white sage, bee sage, or sacred sage) is an evergreen.pdf
anjalipub
 
Q.2 steps required to implement ABC within the companyABC Costing .pdf
Q.2 steps required to implement ABC within the companyABC Costing .pdfQ.2 steps required to implement ABC within the companyABC Costing .pdf
Q.2 steps required to implement ABC within the companyABC Costing .pdf
anjalipub
 
Molecular clocks use mutations to estimate evolutionary time. They c.pdf
Molecular clocks use mutations to estimate evolutionary time. They c.pdfMolecular clocks use mutations to estimate evolutionary time. They c.pdf
Molecular clocks use mutations to estimate evolutionary time. They c.pdf
anjalipub
 
Last mile in VOIP-1)Last mile isthe telecommunications and techno.pdf
Last mile in VOIP-1)Last mile isthe telecommunications and techno.pdfLast mile in VOIP-1)Last mile isthe telecommunications and techno.pdf
Last mile in VOIP-1)Last mile isthe telecommunications and techno.pdf
anjalipub
 
fSolutionf.pdf
fSolutionf.pdffSolutionf.pdf
fSolutionf.pdf
anjalipub
 
For more informationcontact South-Western,5191 Natorp Boulevard,Maso.pdf
For more informationcontact South-Western,5191 Natorp Boulevard,Maso.pdfFor more informationcontact South-Western,5191 Natorp Boulevard,Maso.pdf
For more informationcontact South-Western,5191 Natorp Boulevard,Maso.pdf
anjalipub
 
answer is option (D) as in IUPAC we use numerals .pdf
                     answer is option (D) as in IUPAC we use numerals .pdf                     answer is option (D) as in IUPAC we use numerals .pdf
answer is option (D) as in IUPAC we use numerals .pdf
anjalipub
 

More from anjalipub (20)

when substance dissolves consider following two c.pdf
                     when substance dissolves consider following two c.pdf                     when substance dissolves consider following two c.pdf
when substance dissolves consider following two c.pdf
 
Molarity = molevolume(L) moles of HONH2 = 0.500.pdf
                     Molarity = molevolume(L) moles of HONH2 = 0.500.pdf                     Molarity = molevolume(L) moles of HONH2 = 0.500.pdf
Molarity = molevolume(L) moles of HONH2 = 0.500.pdf
 
l=1 means p-orbital which is havind domble shape .pdf
                     l=1 means p-orbital which is havind domble shape .pdf                     l=1 means p-orbital which is havind domble shape .pdf
l=1 means p-orbital which is havind domble shape .pdf
 
It will be due to A because it has a shorter life.pdf
                     It will be due to A because it has a shorter life.pdf                     It will be due to A because it has a shorter life.pdf
It will be due to A because it has a shorter life.pdf
 
isolated .pdf
                     isolated                                      .pdf                     isolated                                      .pdf
isolated .pdf
 
d) inconsistent with the general trend relating c.pdf
                     d) inconsistent with the general trend relating c.pdf                     d) inconsistent with the general trend relating c.pdf
d) inconsistent with the general trend relating c.pdf
 
The yellowbrown coloration is due to the fomation of the triiodide .pdf
The yellowbrown coloration is due to the fomation of the triiodide .pdfThe yellowbrown coloration is due to the fomation of the triiodide .pdf
The yellowbrown coloration is due to the fomation of the triiodide .pdf
 
SolutionCu2+ and CO2, BOTH will behave as a Lewis acid toward OH-.pdf
SolutionCu2+ and CO2, BOTH will behave as a Lewis acid toward OH-.pdfSolutionCu2+ and CO2, BOTH will behave as a Lewis acid toward OH-.pdf
SolutionCu2+ and CO2, BOTH will behave as a Lewis acid toward OH-.pdf
 
TCP provide reliable connection oriented transport of a byte brook U.pdf
TCP provide reliable connection oriented transport of a byte brook U.pdfTCP provide reliable connection oriented transport of a byte brook U.pdf
TCP provide reliable connection oriented transport of a byte brook U.pdf
 
Solution - (E) Calculation of WACC (Weighted average cost of capital.pdf
Solution - (E) Calculation of WACC (Weighted average cost of capital.pdfSolution - (E) Calculation of WACC (Weighted average cost of capital.pdf
Solution - (E) Calculation of WACC (Weighted average cost of capital.pdf
 
Solution           His total Volume          = the volume of wa.pdf
Solution           His total Volume          = the volume of wa.pdfSolution           His total Volume          = the volume of wa.pdf
Solution           His total Volume          = the volume of wa.pdf
 
SQLiteStudio is a SQLite database manager with the following feature.pdf
SQLiteStudio is a SQLite database manager with the following feature.pdfSQLiteStudio is a SQLite database manager with the following feature.pdf
SQLiteStudio is a SQLite database manager with the following feature.pdf
 
C) H2O .pdf
                     C) H2O                                       .pdf                     C) H2O                                       .pdf
C) H2O .pdf
 
Salvia apiana (white sage, bee sage, or sacred sage) is an evergreen.pdf
Salvia apiana (white sage, bee sage, or sacred sage) is an evergreen.pdfSalvia apiana (white sage, bee sage, or sacred sage) is an evergreen.pdf
Salvia apiana (white sage, bee sage, or sacred sage) is an evergreen.pdf
 
Q.2 steps required to implement ABC within the companyABC Costing .pdf
Q.2 steps required to implement ABC within the companyABC Costing .pdfQ.2 steps required to implement ABC within the companyABC Costing .pdf
Q.2 steps required to implement ABC within the companyABC Costing .pdf
 
Molecular clocks use mutations to estimate evolutionary time. They c.pdf
Molecular clocks use mutations to estimate evolutionary time. They c.pdfMolecular clocks use mutations to estimate evolutionary time. They c.pdf
Molecular clocks use mutations to estimate evolutionary time. They c.pdf
 
Last mile in VOIP-1)Last mile isthe telecommunications and techno.pdf
Last mile in VOIP-1)Last mile isthe telecommunications and techno.pdfLast mile in VOIP-1)Last mile isthe telecommunications and techno.pdf
Last mile in VOIP-1)Last mile isthe telecommunications and techno.pdf
 
fSolutionf.pdf
fSolutionf.pdffSolutionf.pdf
fSolutionf.pdf
 
For more informationcontact South-Western,5191 Natorp Boulevard,Maso.pdf
For more informationcontact South-Western,5191 Natorp Boulevard,Maso.pdfFor more informationcontact South-Western,5191 Natorp Boulevard,Maso.pdf
For more informationcontact South-Western,5191 Natorp Boulevard,Maso.pdf
 
answer is option (D) as in IUPAC we use numerals .pdf
                     answer is option (D) as in IUPAC we use numerals .pdf                     answer is option (D) as in IUPAC we use numerals .pdf
answer is option (D) as in IUPAC we use numerals .pdf
 

Recently uploaded

The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 

Recently uploaded (20)

The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 

    #include STDIO.H     int main() {        char file_name[.pdf

  • 1. #include int main() { char file_name[20], guess[6]; char Life[15][15]; int ctr=0, ctr2=0; char *g; FILE *fp1; int i, j; int neighbors; printf ("Enter file_name of initial generation: "); scanf ("%s", file_name); fp1 = fopen(file_name, "r"); do { g = fgets (guess, 6, fp1); for(ctr2=0;ctr2<6;ctr2++){ Life[ctr][ctr2]=g[ctr2]; } ctr++; if (g!=NULL) printf ("%s", guess); } while (g != NULL); fclose (fp1); printf (" "); neighbors=0; for (i=0; i<4; i++) { for (j=0; j<4; j++) { if (i==0 && j==0) { if (Life [i+1][j]=='X') neighbors ++; if (Life [i][j+1]=='X') neighbors ++;
  • 2. if (Life [i+1][j+1]=='X') neighbors ++; } if (i==3 && j==0) { if (Life [i-1][j]=='X') neighbors ++; if (Life [i-1][j+1]=='X') neighbors ++; if (Life [i][j+1]=='X') neighbors ++; } if (i==0 && j==3) { if (Life [i][j-1]=='X') neighbors ++; if (Life [i+1][j-1]=='X') neighbors ++; if (Life [i+1][j]=='X') neighbors ++; } if (i==3 && j==3) { if (Life [i][j-1]=='X') neighbors ++; if (Life [i-1][j-1]=='X') neighbors ++; if (Life [i-1][j]=='X') neighbors ++; } if (j==0 && i!=0 && i!=3) { if (Life [i-1][j]=='X') neighbors ++; if (Life [i-1][j+1]=='X') neighbors ++; if (Life [i][j+1]=='X') neighbors ++; if (Life [i+1][j]=='X') neighbors ++;
  • 3. if (Life [i+1][j+1]=='X') neighbors ++; } if (j==3 && i!=0 && i!=3) { if (Life [i-1][j]=='X') neighbors ++; if (Life [i-1][j-1]=='X') neighbors ++; if (Life [i][j-1]=='X') neighbors ++; if (Life [i+1][j-1]=='X') neighbors ++; if (Life [i+1][j+1]=='X') neighbors ++; } if (i==0 && j!=0 && j!=3) { if (Life [i][j-1]=='X') neighbors ++; if (Life [i][j+1]=='X') neighbors ++; if (Life [i+1][j-1]=='X') neighbors ++; if (Life [i+1][j]=='X') neighbors ++; if (Life [i+1][j+1]=='X') neighbors ++; } if (i==3 && j!=0 && j!=3) { if (Life [i][j-1]=='X') neighbors ++; if (Life [i][j+1]=='X') neighbors ++; if (Life [i-1][j-1]=='X') neighbors ++; if (Life [i-1][j]=='X') neighbors ++;
  • 4. if (Life [i-1][j+1]=='X') neighbors ++; } if (i!=0 && i!=3 && j!=0 && j!=3) { if (Life [i][j+1]=='X') neighbors ++; if (Life [i][j-1]=='X') neighbors ++; if (Life [i-1][j]=='X') neighbors ++; if (Life [i-1][j+1]=='X') neighbors ++; if (Life [i-1][j-1]=='X') neighbors ++; if (Life [i+1][j]=='X') neighbors ++; if (Life [i+1][j+1]=='X') neighbors ++; if (Life [i+1][j-1]=='X') } neighbors ++; } } for (i=0; i<4; i++) { for (j=0; j<4; j++) { if (Life [i][j]==' ') { if (neighbors==3) Life [i][j]='X'; else Life [i][j]=' '; } if (Life [i][j]=='X') { if (neighbors==2 && neighbors==3) Life [i][j]='X'; else
  • 5. Life [i][j]=' '; } } } printf ("The new generation is: "); printf ("%s", Life[i][j]); return 0; } Solution #include int main() { char file_name[20], guess[6]; char Life[15][15]; int ctr=0, ctr2=0; char *g; FILE *fp1; int i, j; int neighbors; printf ("Enter file_name of initial generation: "); scanf ("%s", file_name); fp1 = fopen(file_name, "r"); do { g = fgets (guess, 6, fp1); for(ctr2=0;ctr2<6;ctr2++){ Life[ctr][ctr2]=g[ctr2]; } ctr++; if (g!=NULL) printf ("%s", guess); } while (g != NULL);
  • 6. fclose (fp1); printf (" "); neighbors=0; for (i=0; i<4; i++) { for (j=0; j<4; j++) { if (i==0 && j==0) { if (Life [i+1][j]=='X') neighbors ++; if (Life [i][j+1]=='X') neighbors ++; if (Life [i+1][j+1]=='X') neighbors ++; } if (i==3 && j==0) { if (Life [i-1][j]=='X') neighbors ++; if (Life [i-1][j+1]=='X') neighbors ++; if (Life [i][j+1]=='X') neighbors ++; } if (i==0 && j==3) { if (Life [i][j-1]=='X') neighbors ++; if (Life [i+1][j-1]=='X') neighbors ++; if (Life [i+1][j]=='X') neighbors ++; } if (i==3 && j==3) { if (Life [i][j-1]=='X') neighbors ++; if (Life [i-1][j-1]=='X') neighbors ++; if (Life [i-1][j]=='X')
  • 7. neighbors ++; } if (j==0 && i!=0 && i!=3) { if (Life [i-1][j]=='X') neighbors ++; if (Life [i-1][j+1]=='X') neighbors ++; if (Life [i][j+1]=='X') neighbors ++; if (Life [i+1][j]=='X') neighbors ++; if (Life [i+1][j+1]=='X') neighbors ++; } if (j==3 && i!=0 && i!=3) { if (Life [i-1][j]=='X') neighbors ++; if (Life [i-1][j-1]=='X') neighbors ++; if (Life [i][j-1]=='X') neighbors ++; if (Life [i+1][j-1]=='X') neighbors ++; if (Life [i+1][j+1]=='X') neighbors ++; } if (i==0 && j!=0 && j!=3) { if (Life [i][j-1]=='X') neighbors ++; if (Life [i][j+1]=='X') neighbors ++; if (Life [i+1][j-1]=='X') neighbors ++; if (Life [i+1][j]=='X') neighbors ++; if (Life [i+1][j+1]=='X')
  • 8. neighbors ++; } if (i==3 && j!=0 && j!=3) { if (Life [i][j-1]=='X') neighbors ++; if (Life [i][j+1]=='X') neighbors ++; if (Life [i-1][j-1]=='X') neighbors ++; if (Life [i-1][j]=='X') neighbors ++; if (Life [i-1][j+1]=='X') neighbors ++; } if (i!=0 && i!=3 && j!=0 && j!=3) { if (Life [i][j+1]=='X') neighbors ++; if (Life [i][j-1]=='X') neighbors ++; if (Life [i-1][j]=='X') neighbors ++; if (Life [i-1][j+1]=='X') neighbors ++; if (Life [i-1][j-1]=='X') neighbors ++; if (Life [i+1][j]=='X') neighbors ++; if (Life [i+1][j+1]=='X') neighbors ++; if (Life [i+1][j-1]=='X') } neighbors ++; } } for (i=0; i<4; i++) { for (j=0; j<4; j++) {
  • 9. if (Life [i][j]==' ') { if (neighbors==3) Life [i][j]='X'; else Life [i][j]=' '; } if (Life [i][j]=='X') { if (neighbors==2 && neighbors==3) Life [i][j]='X'; else Life [i][j]=' '; } } } printf ("The new generation is: "); printf ("%s", Life[i][j]); return 0; }