SlideShare une entreprise Scribd logo
1  sur  2
Télécharger pour lire hors ligne
What is the output of this code? what to put when it prompts to enter the file name? Give specific
replys. Show the demo of the output.
#include<bits/stdc++.h>
#include<fstream>
#include <iostream>
#include<cstdlib>
#include<string.h>
using namespace std;
int c=0;
ifstream fin;
int strcmp_ncase(string s1, string s2)
{
transform(s1.begin(),s1.end(),s1.begin(), ::toupper);
transform(s2.begin(),s2.end(),s2.begin(), ::toupper);
if(s1 == s2)
return 1;
else
return 0;
}
int main()
{
cout<<"Welcome to the Name Searching Programn";
char fil[100];
cout<<"Please enter the name your file: ";
cin>>fil;
fin.open(fil);
while(fin.fail())
{
cout << "I'm sorry, I could not open " << fil <<
" Please enter another name: ";
cin>>fil;
fin.open(fil);
}
cout << "File" << fil << "opened successfullyn";
getchar();
string search;
cout<<"What name would like to find in the file? ";
getline(cin, search);
int flag = 0;
while(!fin.eof())
{
string temp;
c++;
getline(fin,temp);
int x = strcmp_ncase(search,temp);
if(x == 1)
{
cout <<""<< temp << "is the"<<c<<"rd name in the file"<<endl;
flag = 1;
}
}
if(flag == 0)
cout<<search<<"name not found in the filen";
fin.close();
cout<<"Thank you for using he NSPn";
return 0;
}

Contenu connexe

Similaire à What is the output of this code- what to put when it prompts to enter.pdf

Write a C++ program 1. Study the function process_text() in file.pdf
Write a C++ program 1. Study the function process_text() in file.pdfWrite a C++ program 1. Study the function process_text() in file.pdf
Write a C++ program 1. Study the function process_text() in file.pdf
jillisacebi75827
 
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docxLab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
DIPESH30
 
Shell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdfShell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdf
clarityvision
 
Can someone explain me the steps pleaseTake the provided files.pdf
Can someone explain me the steps pleaseTake the provided files.pdfCan someone explain me the steps pleaseTake the provided files.pdf
Can someone explain me the steps pleaseTake the provided files.pdf
info189835
 
3 1. preprocessor, math, stdlib
3 1. preprocessor, math, stdlib3 1. preprocessor, math, stdlib
3 1. preprocessor, math, stdlib
웅식 전
 
C++ course start
C++ course startC++ course start
C++ course start
Net3lem
 
Dns server clients (actual program)
Dns server clients (actual program)Dns server clients (actual program)
Dns server clients (actual program)
Youssef Dirani
 
Dns server clients (actual program)
Dns server clients (actual program)Dns server clients (actual program)
Dns server clients (actual program)
Youssef Dirani
 

Similaire à What is the output of this code- what to put when it prompts to enter.pdf (20)

Write a C++ program 1. Study the function process_text() in file.pdf
Write a C++ program 1. Study the function process_text() in file.pdfWrite a C++ program 1. Study the function process_text() in file.pdf
Write a C++ program 1. Study the function process_text() in file.pdf
 
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docxLab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
 
Computer Programming- Lecture 6
Computer Programming- Lecture 6Computer Programming- Lecture 6
Computer Programming- Lecture 6
 
Shell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdfShell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdf
 
Add an interactive command line to your C++ application
Add an interactive command line to your C++ applicationAdd an interactive command line to your C++ application
Add an interactive command line to your C++ application
 
Unix Programs
Unix ProgramsUnix Programs
Unix Programs
 
lecture-5 string.pptx
lecture-5 string.pptxlecture-5 string.pptx
lecture-5 string.pptx
 
Game unleashedjavascript
Game unleashedjavascriptGame unleashedjavascript
Game unleashedjavascript
 
Sbaw091006
Sbaw091006Sbaw091006
Sbaw091006
 
20DCE096_prac8.pdf
20DCE096_prac8.pdf20DCE096_prac8.pdf
20DCE096_prac8.pdf
 
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic LabsTypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
 
Can someone explain me the steps pleaseTake the provided files.pdf
Can someone explain me the steps pleaseTake the provided files.pdfCan someone explain me the steps pleaseTake the provided files.pdf
Can someone explain me the steps pleaseTake the provided files.pdf
 
C++11
C++11C++11
C++11
 
3 1. preprocessor, math, stdlib
3 1. preprocessor, math, stdlib3 1. preprocessor, math, stdlib
3 1. preprocessor, math, stdlib
 
C++ course start
C++ course startC++ course start
C++ course start
 
Dns server clients (actual program)
Dns server clients (actual program)Dns server clients (actual program)
Dns server clients (actual program)
 
Dns server clients (actual program)
Dns server clients (actual program)Dns server clients (actual program)
Dns server clients (actual program)
 
Tugas 2
Tugas 2Tugas 2
Tugas 2
 
MUST CS101 Lab11
MUST CS101 Lab11 MUST CS101 Lab11
MUST CS101 Lab11
 
Library functions in c++
Library functions in c++Library functions in c++
Library functions in c++
 

Plus de JoshuaQ1NReesh

What is the complete code for this problem- Create a KakuroCSP solver.pdf
What is the complete code for this problem- Create a KakuroCSP solver.pdfWhat is the complete code for this problem- Create a KakuroCSP solver.pdf
What is the complete code for this problem- Create a KakuroCSP solver.pdf
JoshuaQ1NReesh
 
What is the complete code for this problem- DON'T POST A MISSING CODE.pdf
What is the complete code for this problem-  DON'T POST A MISSING CODE.pdfWhat is the complete code for this problem-  DON'T POST A MISSING CODE.pdf
What is the complete code for this problem- DON'T POST A MISSING CODE.pdf
JoshuaQ1NReesh
 

Plus de JoshuaQ1NReesh (20)

What makes an organism alive- what are the characteristics of life- Is.pdf
What makes an organism alive- what are the characteristics of life- Is.pdfWhat makes an organism alive- what are the characteristics of life- Is.pdf
What makes an organism alive- what are the characteristics of life- Is.pdf
 
What is the variance in Table 1- Table 1- Raw data of hospital emergen.pdf
What is the variance in Table 1- Table 1- Raw data of hospital emergen.pdfWhat is the variance in Table 1- Table 1- Raw data of hospital emergen.pdf
What is the variance in Table 1- Table 1- Raw data of hospital emergen.pdf
 
What is the World Economic Forum- Who is the founder- There is a divid.pdf
What is the World Economic Forum- Who is the founder- There is a divid.pdfWhat is the World Economic Forum- Who is the founder- There is a divid.pdf
What is the World Economic Forum- Who is the founder- There is a divid.pdf
 
What is the total assets- Determine the total assets for the period fr.pdf
What is the total assets- Determine the total assets for the period fr.pdfWhat is the total assets- Determine the total assets for the period fr.pdf
What is the total assets- Determine the total assets for the period fr.pdf
 
What is the total expense for the period- The following information is.pdf
What is the total expense for the period- The following information is.pdfWhat is the total expense for the period- The following information is.pdf
What is the total expense for the period- The following information is.pdf
 
What is the significance of the image below-Represent the deposition o.pdf
What is the significance of the image below-Represent the deposition o.pdfWhat is the significance of the image below-Represent the deposition o.pdf
What is the significance of the image below-Represent the deposition o.pdf
 
What is the statistical term for moderation- Repeated group effect Int.pdf
What is the statistical term for moderation- Repeated group effect Int.pdfWhat is the statistical term for moderation- Repeated group effect Int.pdf
What is the statistical term for moderation- Repeated group effect Int.pdf
 
what is the primary purpose of financial accounting - what is the prim.pdf
what is the primary purpose of financial accounting - what is the prim.pdfwhat is the primary purpose of financial accounting - what is the prim.pdf
what is the primary purpose of financial accounting - what is the prim.pdf
 
What is the present value of the following cash flows at a rate of 4-8.pdf
What is the present value of the following cash flows at a rate of 4-8.pdfWhat is the present value of the following cash flows at a rate of 4-8.pdf
What is the present value of the following cash flows at a rate of 4-8.pdf
 
What is the net profit- Assume the following information was made avai.pdf
What is the net profit- Assume the following information was made avai.pdfWhat is the net profit- Assume the following information was made avai.pdf
What is the net profit- Assume the following information was made avai.pdf
 
What is the major difference between a population and a sample in a re.pdf
What is the major difference between a population and a sample in a re.pdfWhat is the major difference between a population and a sample in a re.pdf
What is the major difference between a population and a sample in a re.pdf
 
What is the main difference between onboarding and training- Onboardin.pdf
What is the main difference between onboarding and training- Onboardin.pdfWhat is the main difference between onboarding and training- Onboardin.pdf
What is the main difference between onboarding and training- Onboardin.pdf
 
What is the journal entry when the company pays $800 cash on accounts.pdf
What is the journal entry when the company pays $800 cash on accounts.pdfWhat is the journal entry when the company pays $800 cash on accounts.pdf
What is the journal entry when the company pays $800 cash on accounts.pdf
 
What is the difference between sterilisation and disinfection- Name th.pdf
What is the difference between sterilisation and disinfection- Name th.pdfWhat is the difference between sterilisation and disinfection- Name th.pdf
What is the difference between sterilisation and disinfection- Name th.pdf
 
What is the complete code for this problem- Create a KakuroCSP solver.pdf
What is the complete code for this problem- Create a KakuroCSP solver.pdfWhat is the complete code for this problem- Create a KakuroCSP solver.pdf
What is the complete code for this problem- Create a KakuroCSP solver.pdf
 
What is scikit learn in python used for--The components of the scikit.pdf
What is scikit learn in python used for--The components of the scikit.pdfWhat is scikit learn in python used for--The components of the scikit.pdf
What is scikit learn in python used for--The components of the scikit.pdf
 
What is included in the resources system developed by ASOS to supports.pdf
What is included in the resources system developed by ASOS to supports.pdfWhat is included in the resources system developed by ASOS to supports.pdf
What is included in the resources system developed by ASOS to supports.pdf
 
What is the complete code for this problem- DON'T POST A MISSING CODE.pdf
What is the complete code for this problem-  DON'T POST A MISSING CODE.pdfWhat is the complete code for this problem-  DON'T POST A MISSING CODE.pdf
What is the complete code for this problem- DON'T POST A MISSING CODE.pdf
 
What is a measure of the status of redox reactions in a given water- W.pdf
What is a measure of the status of redox reactions in a given water- W.pdfWhat is a measure of the status of redox reactions in a given water- W.pdf
What is a measure of the status of redox reactions in a given water- W.pdf
 
What is a controlled experiment- Uses both a training group and a cont.pdf
What is a controlled experiment- Uses both a training group and a cont.pdfWhat is a controlled experiment- Uses both a training group and a cont.pdf
What is a controlled experiment- Uses both a training group and a cont.pdf
 

Dernier

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Dernier (20)

Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 

What is the output of this code- what to put when it prompts to enter.pdf

  • 1. What is the output of this code? what to put when it prompts to enter the file name? Give specific replys. Show the demo of the output. #include<bits/stdc++.h> #include<fstream> #include <iostream> #include<cstdlib> #include<string.h> using namespace std; int c=0; ifstream fin; int strcmp_ncase(string s1, string s2) { transform(s1.begin(),s1.end(),s1.begin(), ::toupper); transform(s2.begin(),s2.end(),s2.begin(), ::toupper); if(s1 == s2) return 1; else return 0; } int main() { cout<<"Welcome to the Name Searching Programn"; char fil[100]; cout<<"Please enter the name your file: "; cin>>fil; fin.open(fil); while(fin.fail()) { cout << "I'm sorry, I could not open " << fil << " Please enter another name: "; cin>>fil; fin.open(fil); }
  • 2. cout << "File" << fil << "opened successfullyn"; getchar(); string search; cout<<"What name would like to find in the file? "; getline(cin, search); int flag = 0; while(!fin.eof()) { string temp; c++; getline(fin,temp); int x = strcmp_ncase(search,temp); if(x == 1) { cout <<""<< temp << "is the"<<c<<"rd name in the file"<<endl; flag = 1; } } if(flag == 0) cout<<search<<"name not found in the filen"; fin.close(); cout<<"Thank you for using he NSPn"; return 0; }