SlideShare a Scribd company logo
1 of 3
Download to read offline
#include <stdio.h>
#include <string.h>
#define MAX_USERS 100
struct user {
char username[20];
char password[20];
char codeword[20];
};
int num_users = 0;
struct user users[MAX_USERS];
int find_user_index(char *username) {
for (int i = 0; i < num_users; i++) {
if (strcmp(users[i].username, username) == 0) {
return i;
}
}
return -1;
}
void add_user() {
if (num_users == MAX_USERS) {
printf("Error: maximum number of users reachedn");
return;
}
struct user u;
printf("Enter username: ");
scanf("%s", u.username);
printf("Enter password: ");
scanf("%s", u.password);
printf("Enter codeword: ");
scanf("%s", u.codeword);
users[num_users++] = u;
}
void edit_user() {
char username[20];
printf("Enter username to edit: ");
scanf("%s", username);
int i = find_user_index(username);
if (i == -1) {
printf("Error: user not foundn");
return;
}
struct user u = users[i];
printf("Enter new password (or press enter to keep current password): ");
scanf("%s", u.password);
printf("Enter new codeword (or press enter to keep current codeword): ");
scanf("%s", u.codeword);
users[i] = u;
}
void display_users() {
printf("%-20s %-20s %-20sn", "Username", "Password", "Codeword");
for (int i = 0; i < num_users; i++) {
printf("%-20s %-20s %-20sn", users[i].username, users[i].password, users[i].codeword);
}
}
void remove_user() {
char username[20];
printf("Enter username to remove: ");
scanf("%s", username);
int i = find_user_index(username);
if (i == -1) {
printf("Error: user not foundn");
return;
}
for (int j = i; j < num_users - 1; j++) {
users[j] = users[j + 1];
}
num_users--;
}
int main() {
int choice;
while (1) {
printf("n");
printf("1. Add usern");
printf("2. Edit usern");
printf("3. Display usersn");
printf("4. Remove usern");
printf("5. Exitn");
printf("Enter choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
add_user();
break;
case 2:
edit_user();
break;
case 3:
display_users();
break;
case 4:
remove_user();
break;
case 5:
return 0;
default:
printf("Error: invalid choicen");
}
}
}
Based on the code above, provide the necessary comments in the code.

More Related Content

Similar to include ltstdiohgt include ltstringhgt define M.pdf

User.DS_Store__MACOSXUser._.DS_Store__MACOSXUser._D.docx
User.DS_Store__MACOSXUser._.DS_Store__MACOSXUser._D.docxUser.DS_Store__MACOSXUser._.DS_Store__MACOSXUser._D.docx
User.DS_Store__MACOSXUser._.DS_Store__MACOSXUser._D.docxdickonsondorris
 
from datetime import datetime def CreateUsers()- print('##### Crea.pdf
from datetime import datetime def CreateUsers()-     print('##### Crea.pdffrom datetime import datetime def CreateUsers()-     print('##### Crea.pdf
from datetime import datetime def CreateUsers()- print('##### Crea.pdfatozworkwear
 
Program to sort the n names in an alphabetical order
Program to sort the n names in an alphabetical orderProgram to sort the n names in an alphabetical order
Program to sort the n names in an alphabetical orderSamsil Arefin
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical FileAshwin Francis
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical fileMitul Patel
 
Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»e-Legion
 
Mozilla とブラウザゲーム
Mozilla とブラウザゲームMozilla とブラウザゲーム
Mozilla とブラウザゲームNoritada Shimizu
 
C programming structure & pointer
C  programming structure & pointerC  programming structure & pointer
C programming structure & pointerargusacademy
 
STRUCTURES IN C PROGRAMMING
STRUCTURES IN C PROGRAMMING STRUCTURES IN C PROGRAMMING
STRUCTURES IN C PROGRAMMING Gurwinderkaur45
 
I have this error variable stdstringstream ss has initi.pdf
I have this error variable stdstringstream ss has initi.pdfI have this error variable stdstringstream ss has initi.pdf
I have this error variable stdstringstream ss has initi.pdfsukhvir71
 
Статичный SQL в С++14. Евгений Захаров ➠ CoreHard Autumn 2019
Статичный SQL в С++14. Евгений Захаров ➠  CoreHard Autumn 2019Статичный SQL в С++14. Евгений Захаров ➠  CoreHard Autumn 2019
Статичный SQL в С++14. Евгений Захаров ➠ CoreHard Autumn 2019corehard_by
 
Creating a Whatsapp Clone - Part XIII - Transcript.pdf
Creating a Whatsapp Clone - Part XIII - Transcript.pdfCreating a Whatsapp Clone - Part XIII - Transcript.pdf
Creating a Whatsapp Clone - Part XIII - Transcript.pdfShaiAlmog1
 
C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st StudyChris Ohk
 
Intro programacion funcional
Intro programacion funcionalIntro programacion funcional
Intro programacion funcionalNSCoder Mexico
 
JAVA PRACTICE QUESTIONS v1.4.pdf
JAVA PRACTICE QUESTIONS v1.4.pdfJAVA PRACTICE QUESTIONS v1.4.pdf
JAVA PRACTICE QUESTIONS v1.4.pdfRohitkumarYadav80
 
Assignment no39
Assignment no39Assignment no39
Assignment no39Jay Patel
 

Similar to include ltstdiohgt include ltstringhgt define M.pdf (20)

Railwaynew
RailwaynewRailwaynew
Railwaynew
 
User.DS_Store__MACOSXUser._.DS_Store__MACOSXUser._D.docx
User.DS_Store__MACOSXUser._.DS_Store__MACOSXUser._D.docxUser.DS_Store__MACOSXUser._.DS_Store__MACOSXUser._D.docx
User.DS_Store__MACOSXUser._.DS_Store__MACOSXUser._D.docx
 
from datetime import datetime def CreateUsers()- print('##### Crea.pdf
from datetime import datetime def CreateUsers()-     print('##### Crea.pdffrom datetime import datetime def CreateUsers()-     print('##### Crea.pdf
from datetime import datetime def CreateUsers()- print('##### Crea.pdf
 
Program to sort the n names in an alphabetical order
Program to sort the n names in an alphabetical orderProgram to sort the n names in an alphabetical order
Program to sort the n names in an alphabetical order
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
SaraPIC
SaraPICSaraPIC
SaraPIC
 
4. chapter iii
4. chapter iii4. chapter iii
4. chapter iii
 
C programming
C programmingC programming
C programming
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
 
Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»
 
Mozilla とブラウザゲーム
Mozilla とブラウザゲームMozilla とブラウザゲーム
Mozilla とブラウザゲーム
 
C programming structure & pointer
C  programming structure & pointerC  programming structure & pointer
C programming structure & pointer
 
STRUCTURES IN C PROGRAMMING
STRUCTURES IN C PROGRAMMING STRUCTURES IN C PROGRAMMING
STRUCTURES IN C PROGRAMMING
 
I have this error variable stdstringstream ss has initi.pdf
I have this error variable stdstringstream ss has initi.pdfI have this error variable stdstringstream ss has initi.pdf
I have this error variable stdstringstream ss has initi.pdf
 
Статичный SQL в С++14. Евгений Захаров ➠ CoreHard Autumn 2019
Статичный SQL в С++14. Евгений Захаров ➠  CoreHard Autumn 2019Статичный SQL в С++14. Евгений Захаров ➠  CoreHard Autumn 2019
Статичный SQL в С++14. Евгений Захаров ➠ CoreHard Autumn 2019
 
Creating a Whatsapp Clone - Part XIII - Transcript.pdf
Creating a Whatsapp Clone - Part XIII - Transcript.pdfCreating a Whatsapp Clone - Part XIII - Transcript.pdf
Creating a Whatsapp Clone - Part XIII - Transcript.pdf
 
C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st Study
 
Intro programacion funcional
Intro programacion funcionalIntro programacion funcional
Intro programacion funcional
 
JAVA PRACTICE QUESTIONS v1.4.pdf
JAVA PRACTICE QUESTIONS v1.4.pdfJAVA PRACTICE QUESTIONS v1.4.pdf
JAVA PRACTICE QUESTIONS v1.4.pdf
 
Assignment no39
Assignment no39Assignment no39
Assignment no39
 

More from adisainternational

Insert a function in cell D11 to display the ltem name based.pdf
Insert a function in cell D11 to display the ltem name based.pdfInsert a function in cell D11 to display the ltem name based.pdf
Insert a function in cell D11 to display the ltem name based.pdfadisainternational
 
Insert Document To Collection nbdaproject36vents VIEW P.pdf
Insert Document To Collection nbdaproject36vents VIEW  P.pdfInsert Document To Collection nbdaproject36vents VIEW  P.pdf
Insert Document To Collection nbdaproject36vents VIEW P.pdfadisainternational
 
innervates posterior 13 of tongue taste 2 Wordscran.pdf
innervates posterior 13 of tongue  taste  2 Wordscran.pdfinnervates posterior 13 of tongue  taste  2 Wordscran.pdf
innervates posterior 13 of tongue taste 2 Wordscran.pdfadisainternational
 
Individually look for the Code of Conduct of a selected comp.pdf
Individually look for the Code of Conduct of a selected comp.pdfIndividually look for the Code of Conduct of a selected comp.pdf
Individually look for the Code of Conduct of a selected comp.pdfadisainternational
 
Influenza is an infectious respiratory disease caused by a .pdf
Influenza is an infectious respiratory disease caused by a .pdfInfluenza is an infectious respiratory disease caused by a .pdf
Influenza is an infectious respiratory disease caused by a .pdfadisainternational
 
include ltstdiohgt include ltstdlibhgt include .pdf
include ltstdiohgt include ltstdlibhgt include .pdfinclude ltstdiohgt include ltstdlibhgt include .pdf
include ltstdiohgt include ltstdlibhgt include .pdfadisainternational
 
Informacin general Anna ha estado hablando con los director.pdf
Informacin general Anna ha estado hablando con los director.pdfInformacin general Anna ha estado hablando con los director.pdf
Informacin general Anna ha estado hablando con los director.pdfadisainternational
 
inflation in india interest rates in india and compare it wi.pdf
inflation in india interest rates in india and compare it wi.pdfinflation in india interest rates in india and compare it wi.pdf
inflation in india interest rates in india and compare it wi.pdfadisainternational
 
Indigenous Peoples and Environmental Sustainability Article .pdf
Indigenous Peoples and Environmental Sustainability Article .pdfIndigenous Peoples and Environmental Sustainability Article .pdf
Indigenous Peoples and Environmental Sustainability Article .pdfadisainternational
 
Information Security Problem a Give the public and private.pdf
Information Security Problem a Give the public and private.pdfInformation Security Problem a Give the public and private.pdf
Information Security Problem a Give the public and private.pdfadisainternational
 
Infertility and Hypothyroidism Patient ProfileMB is a 29y.pdf
Infertility and Hypothyroidism Patient ProfileMB is a 29y.pdfInfertility and Hypothyroidism Patient ProfileMB is a 29y.pdf
Infertility and Hypothyroidism Patient ProfileMB is a 29y.pdfadisainternational
 
inet at pemoning Bret is Bhen the nol asd atenene irpuinise .pdf
inet at pemoning Bret is Bhen the nol asd atenene irpuinise .pdfinet at pemoning Bret is Bhen the nol asd atenene irpuinise .pdf
inet at pemoning Bret is Bhen the nol asd atenene irpuinise .pdfadisainternational
 
Indique el diagnstico ms preciso posible Luego indique la.pdf
Indique el diagnstico ms preciso posible Luego indique la.pdfIndique el diagnstico ms preciso posible Luego indique la.pdf
Indique el diagnstico ms preciso posible Luego indique la.pdfadisainternational
 
In user interface design what is typically TRUE Group of a.pdf
In user interface design what is typically TRUE Group of a.pdfIn user interface design what is typically TRUE Group of a.pdf
In user interface design what is typically TRUE Group of a.pdfadisainternational
 
include ltinitializer_listgt include ltiostreamgt .pdf
include ltinitializer_listgt include ltiostreamgt .pdfinclude ltinitializer_listgt include ltiostreamgt .pdf
include ltinitializer_listgt include ltiostreamgt .pdfadisainternational
 
In your opinion What would drive your decisions If you wer.pdf
In your opinion What would drive your decisions If you wer.pdfIn your opinion What would drive your decisions If you wer.pdf
In your opinion What would drive your decisions If you wer.pdfadisainternational
 
Income statement for 2016 Sales are expected to increase by .pdf
Income statement for 2016 Sales are expected to increase by .pdfIncome statement for 2016 Sales are expected to increase by .pdf
Income statement for 2016 Sales are expected to increase by .pdfadisainternational
 
Indicate in the figure below the location of the Stratosphe.pdf
Indicate in the figure below the location of the Stratosphe.pdfIndicate in the figure below the location of the Stratosphe.pdf
Indicate in the figure below the location of the Stratosphe.pdfadisainternational
 
Independent ttest Dependentpaired ttest Oneway ANOVA Two.pdf
Independent ttest Dependentpaired ttest Oneway ANOVA Two.pdfIndependent ttest Dependentpaired ttest Oneway ANOVA Two.pdf
Independent ttest Dependentpaired ttest Oneway ANOVA Two.pdfadisainternational
 
Independent Assortment Two genes Dumb d and Anxious a .pdf
Independent Assortment Two genes Dumb d and Anxious a .pdfIndependent Assortment Two genes Dumb d and Anxious a .pdf
Independent Assortment Two genes Dumb d and Anxious a .pdfadisainternational
 

More from adisainternational (20)

Insert a function in cell D11 to display the ltem name based.pdf
Insert a function in cell D11 to display the ltem name based.pdfInsert a function in cell D11 to display the ltem name based.pdf
Insert a function in cell D11 to display the ltem name based.pdf
 
Insert Document To Collection nbdaproject36vents VIEW P.pdf
Insert Document To Collection nbdaproject36vents VIEW  P.pdfInsert Document To Collection nbdaproject36vents VIEW  P.pdf
Insert Document To Collection nbdaproject36vents VIEW P.pdf
 
innervates posterior 13 of tongue taste 2 Wordscran.pdf
innervates posterior 13 of tongue  taste  2 Wordscran.pdfinnervates posterior 13 of tongue  taste  2 Wordscran.pdf
innervates posterior 13 of tongue taste 2 Wordscran.pdf
 
Individually look for the Code of Conduct of a selected comp.pdf
Individually look for the Code of Conduct of a selected comp.pdfIndividually look for the Code of Conduct of a selected comp.pdf
Individually look for the Code of Conduct of a selected comp.pdf
 
Influenza is an infectious respiratory disease caused by a .pdf
Influenza is an infectious respiratory disease caused by a .pdfInfluenza is an infectious respiratory disease caused by a .pdf
Influenza is an infectious respiratory disease caused by a .pdf
 
include ltstdiohgt include ltstdlibhgt include .pdf
include ltstdiohgt include ltstdlibhgt include .pdfinclude ltstdiohgt include ltstdlibhgt include .pdf
include ltstdiohgt include ltstdlibhgt include .pdf
 
Informacin general Anna ha estado hablando con los director.pdf
Informacin general Anna ha estado hablando con los director.pdfInformacin general Anna ha estado hablando con los director.pdf
Informacin general Anna ha estado hablando con los director.pdf
 
inflation in india interest rates in india and compare it wi.pdf
inflation in india interest rates in india and compare it wi.pdfinflation in india interest rates in india and compare it wi.pdf
inflation in india interest rates in india and compare it wi.pdf
 
Indigenous Peoples and Environmental Sustainability Article .pdf
Indigenous Peoples and Environmental Sustainability Article .pdfIndigenous Peoples and Environmental Sustainability Article .pdf
Indigenous Peoples and Environmental Sustainability Article .pdf
 
Information Security Problem a Give the public and private.pdf
Information Security Problem a Give the public and private.pdfInformation Security Problem a Give the public and private.pdf
Information Security Problem a Give the public and private.pdf
 
Infertility and Hypothyroidism Patient ProfileMB is a 29y.pdf
Infertility and Hypothyroidism Patient ProfileMB is a 29y.pdfInfertility and Hypothyroidism Patient ProfileMB is a 29y.pdf
Infertility and Hypothyroidism Patient ProfileMB is a 29y.pdf
 
inet at pemoning Bret is Bhen the nol asd atenene irpuinise .pdf
inet at pemoning Bret is Bhen the nol asd atenene irpuinise .pdfinet at pemoning Bret is Bhen the nol asd atenene irpuinise .pdf
inet at pemoning Bret is Bhen the nol asd atenene irpuinise .pdf
 
Indique el diagnstico ms preciso posible Luego indique la.pdf
Indique el diagnstico ms preciso posible Luego indique la.pdfIndique el diagnstico ms preciso posible Luego indique la.pdf
Indique el diagnstico ms preciso posible Luego indique la.pdf
 
In user interface design what is typically TRUE Group of a.pdf
In user interface design what is typically TRUE Group of a.pdfIn user interface design what is typically TRUE Group of a.pdf
In user interface design what is typically TRUE Group of a.pdf
 
include ltinitializer_listgt include ltiostreamgt .pdf
include ltinitializer_listgt include ltiostreamgt .pdfinclude ltinitializer_listgt include ltiostreamgt .pdf
include ltinitializer_listgt include ltiostreamgt .pdf
 
In your opinion What would drive your decisions If you wer.pdf
In your opinion What would drive your decisions If you wer.pdfIn your opinion What would drive your decisions If you wer.pdf
In your opinion What would drive your decisions If you wer.pdf
 
Income statement for 2016 Sales are expected to increase by .pdf
Income statement for 2016 Sales are expected to increase by .pdfIncome statement for 2016 Sales are expected to increase by .pdf
Income statement for 2016 Sales are expected to increase by .pdf
 
Indicate in the figure below the location of the Stratosphe.pdf
Indicate in the figure below the location of the Stratosphe.pdfIndicate in the figure below the location of the Stratosphe.pdf
Indicate in the figure below the location of the Stratosphe.pdf
 
Independent ttest Dependentpaired ttest Oneway ANOVA Two.pdf
Independent ttest Dependentpaired ttest Oneway ANOVA Two.pdfIndependent ttest Dependentpaired ttest Oneway ANOVA Two.pdf
Independent ttest Dependentpaired ttest Oneway ANOVA Two.pdf
 
Independent Assortment Two genes Dumb d and Anxious a .pdf
Independent Assortment Two genes Dumb d and Anxious a .pdfIndependent Assortment Two genes Dumb d and Anxious a .pdf
Independent Assortment Two genes Dumb d and Anxious a .pdf
 

Recently uploaded

Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 

Recently uploaded (20)

Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 

include ltstdiohgt include ltstringhgt define M.pdf

  • 1. #include <stdio.h> #include <string.h> #define MAX_USERS 100 struct user { char username[20]; char password[20]; char codeword[20]; }; int num_users = 0; struct user users[MAX_USERS]; int find_user_index(char *username) { for (int i = 0; i < num_users; i++) { if (strcmp(users[i].username, username) == 0) { return i; } } return -1; } void add_user() { if (num_users == MAX_USERS) { printf("Error: maximum number of users reachedn"); return; } struct user u; printf("Enter username: "); scanf("%s", u.username); printf("Enter password: "); scanf("%s", u.password); printf("Enter codeword: "); scanf("%s", u.codeword); users[num_users++] = u; } void edit_user() { char username[20]; printf("Enter username to edit: "); scanf("%s", username); int i = find_user_index(username); if (i == -1) { printf("Error: user not foundn"); return; } struct user u = users[i];
  • 2. printf("Enter new password (or press enter to keep current password): "); scanf("%s", u.password); printf("Enter new codeword (or press enter to keep current codeword): "); scanf("%s", u.codeword); users[i] = u; } void display_users() { printf("%-20s %-20s %-20sn", "Username", "Password", "Codeword"); for (int i = 0; i < num_users; i++) { printf("%-20s %-20s %-20sn", users[i].username, users[i].password, users[i].codeword); } } void remove_user() { char username[20]; printf("Enter username to remove: "); scanf("%s", username); int i = find_user_index(username); if (i == -1) { printf("Error: user not foundn"); return; } for (int j = i; j < num_users - 1; j++) { users[j] = users[j + 1]; } num_users--; } int main() { int choice; while (1) { printf("n"); printf("1. Add usern"); printf("2. Edit usern"); printf("3. Display usersn"); printf("4. Remove usern"); printf("5. Exitn"); printf("Enter choice: "); scanf("%d", &choice); switch (choice) { case 1: add_user(); break; case 2:
  • 3. edit_user(); break; case 3: display_users(); break; case 4: remove_user(); break; case 5: return 0; default: printf("Error: invalid choicen"); } } } Based on the code above, provide the necessary comments in the code.