EvoNext
1.79K subscribers
272 photos
16 videos
266 files
484 links
Download Telegram
Program Plan: (Question)

• Prompt the user for the file name, try to open the input file, display an error message and exit the program if the file name is not found.

• Read the first number from the file using the if-condition which reads a number from the file, if any number exists in the file. If no numbers exist in the file, this condition stands failed.

• Repeat a while loop to read all numbers in the file and to find the largest and smallest number in the file.

• Display the largest and smallest numbers in the file.

• Display a message to the user if the file contains no numbers that the file is empty.
ANSWER: »https://t.me/learntocodecpp/399«
🔥1
Forwarded from Algo programmers
GENERICS IN C++
👉🏽Generics is the idea to allow type (Integer, String, … etc and user-defined types) to be a parameter to methods, classes and interfaces. For example, classes like an array, map, etc, which can be used using generics very efficiently.

Generics can be implemented in C++ using Templates. Template is a simple and yet very powerful tool in C++. The simple idea is to pass data type as a parameter so that we don’t need to write the same code for different data types.

For example let's look the program that sort() using the idea of generics:_

#include <iostream>
using namespace std;

// One function works for all data types.
// This would work even for user defined types
// if operator '>' is overloaded
template <typename T>

T myMax(T x, T y)
{
return (x > y) ? x : y;
}

int main()
{

// Call myMax for int
cout << myMax<int>(3, 7) << endl;

// call myMax for double
cout << myMax<double>(3.0, 7.0) << endl;

// call myMax for char
cout << myMax<char>('g', 'e') << endl;

return 0;
}
👍1
Class is declared using the class keyword, and structure is declared using the struct keyword. //C++
👍1
#include<iostream>

using namespace std; main() { int i = 1, j = 2, k = 3, r; r = (i, j, k); cout<<r<<endl; //the output is:
Anonymous Poll
24%
1
27%
3
13%
2
58%
compiler error
#include<iostream>

using namespace std; main() { int a[] = {10, 20, 30}; cout<<*a+1; }
Anonymous Poll
12%
10
37%
20
39%
11
17%
21
👍1
#include<iostream>

using namespace std; main() { int a[] = {1, 2}, *p = a; cout<<p[1]; }
Anonymous Poll
16%
1
45%
2
28%
compiler error
16%
runtime error
👍1
Chapter 8 .pdf
2.1 MB
👍1
Error handling during file operations in C/C++

It is quite common that errors may occur while reading data from a file in C++ or writing data to a file.

Below are some Error handling functions during file operations in C/C++:
ferror():
❤️The ferror() function checks for any error in the stream. It returns a value zero if no error has occurred and a non-zero value if there is an error.

»sample code: https://t.me/learntocodecpp/454

clearerr():

🖤The function clearerr() is used to clear the end-of-file and error indicators for the stream.

»sample code: https://t.me/learntocodecpp/457

The function perror()
🤍stands for print error. In case of an error, the programmer can determine the type of error that has occurred using the perror() function.
»sample : https://t.me/learntocodecpp/458
Q1.......is the standard markup language for creating webpages
Anonymous Quiz
12%
Python
7%
C++
78%
Html
4%
C#
the end tag for the HTML element <br> is:
Anonymous Quiz
52%
</br>
11%
</p>
21%
<br> itself
16%
none