Tizimli dasturlash Labaratoriya ishi 2



Download 20,59 Kb.
Sana17.07.2022
Hajmi20,59 Kb.
#815720
Bog'liq
Td lbb2

    Bu sahifa navigatsiya:
  • Guruh

Muhammad Al-Xorazmiy nomidagi Toshkent axborot texnologiyalari universiteti

Fan nomi:Tizimli dasturlash

Labaratoriya ishi 2
Variant №9

Mavzu: Tizimli dasturlash nazariyasining asosiy tushunchalaridan biri bo‘lgan fayl va matnli fayllar bilan ishlash

Guruh: SPP001-L1 
Bajardi:Hamroyev Doniyor
Tekshirdi: Ergashev Sirojiddin
Toshkent -2022
Tizimli dasturlash nazariyasining asosiy tushunchalaridan biri bo‘lgan fayl va matnli fayllar bilan ishlash
1)#include
#include
#include

using namespace std;


//Ghanendra Yadav
int main()
{
ifstream inFile;
char filename[20];

cout<<"Enter The File Name With Extension\n";


cin>>filename;

inFile.open(filename);

/*Here You Have To Create A File And put some data on it. 
Then Save the with Any Extension With File Name As Above Shown */

if (!inFile)


{
cerr << "File example.txt not found." << endl;
return -1;
}

ofstream outFile("sum.txt");


/*Here You Have Sum Of File Line By Line Sum */
string line;

while (getline(inFile, line))


{
if (line.empty()) 
continue;

istringstream iss(line);


int sum = 0, next = 0;
while (iss >> next) 
sum += next;
outFile << sum << endl;
}

inFile.close();


outFile.close();

cout<<"File Created Successfully Go To Sum.txt File And Open\n";

return 0;

2) #include
#include
using namespace std;

int main(void)


{
string test;
test="this is a test"
test.replace(' ','~')// replace the space with ~
cout << test;

return 0

3) #include // function exit() is in cstdlib
#include // class ofstream() is in fstream
#include
#include
using namespace std;

int main()


{
ofstream fout;
ifstream fin; // declare an input file stream
string name;
int x(0);
double avg(0.0);
int sum(0);

cout << "Enter file name: ";


cin >> name;

// open file file_name for input


fin.open(name.c_str(), ios::in);

// check if file is opened for input


if (!fin.is_open())
{
cerr << "Unable to open file " << name << endl;
exit(10);
}

// read text from file


fin >> x;
int ne(0);
int oe(0);
while (!fin.fail())
{
cout << "Read integer: " << x << endl;
fin >> x;

sum += x;


if (x%2 == 0)
{ ne++; }

else
{ oe++;}



}

avg = sum/(ne+oe);



cout << "The sum if the integers is:" << sum << endl;
cout << "The average of the integers is:" << avg << endl;
cout << "The number of even integers is:" << ne << endl;
cout << "The number of odd integers is:" << oe << endl;

Download 20,59 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish