// Filename: EDIT.CPP
#include <iostream.h>
void main()
{
cout << "Visual C++ is easy!";
}
=======================================
// Filename: ERAS.CPP
// Erases the file specified by the user
#include <stdio.h>
#include <iostream.h>
void main()
{
char filename[255];
cout << "What is the filename you want me to erase? ";
cin >> filename;
if (remove(filename))
cout << "*** I could not remove the file ***";
else
cout << "The file " << filename
<< " is now removed";
}
====================
// Filename: EVNTOODD.CPP
// Changes the user's value to the next-highest odd number
#include <iostream.h>
void main()
{
int num;
cout << "Enter an even number: ";
cin >> num;
num |= 1; // Turn on the rightmost bit position
cout << "The next-highest value is " << num << endl;
return;
}
============================
// Filename: EXPRESS.CPP
// Computing expressions with C++
#include <iostream.h>
void main()
{
int ans1, ans2, ans3;
ans1 = 2 * 3 + 3 * 2;
cout << "The first answer is " << ans1 << endl;
ans2 = 20 + 20 / (5 + 5) % 2;
cout << "The second answer is " << ans2 << endl;
ans3 = ((2 + 3) + 6 * (3 + (4 - 2))) + 3;
cout << "The third answer is " << ans3 << endl;
return;
}
Tidak ada komentar:
Posting Komentar