Posts

Showing posts from July, 2017
For more Computer Science, Linux, C++ content visit ProgrammerCave
Follow us on Facebook | Instagram | Telegram

Contribute on Paypal

C++: Understanding Template

Image
C++’s class templates provide a better way to generate generic class declarations. Templates provide parameterized types—that is, they are capable of passing a type name as an  argument to a recipe for building a class or a function. By feeding the type name int to a  Queue template, for example, you can get the compiler to construct a Queue class for queuing  ints . Defining Template:   template < class Typ e>

What is "namespace" and why do we use it?

Image
What is namespace? " In general, a  namespace  is a container for a set of identifiers   Namespaces provide a level of direction to specific identifiers, thus  making it possible to distinguish between identifiers with the same  exact name.  " O r According to Wikipedia “ In  computer programming  namespaces are typically employed for the purpose of grouping symbols and identifiers around a particular functionality and to avoid  name collisions   between multiple identifiers that share the same name. ”

C++: Program to Add and Multiply the digits of a Number

Image
We are the students of Computer Science and Engineering. We have to make many programs in various programming languages. We have to submit them in college assignment work or in school. Many times teacher just taught us the syntax of a language. The logic part has to be done on our own. I have written a post on it. How to improve logical thinking and problem solving skills?

Cool Websites you don't know about...

Sci-Hub :  This website allows you to download research papers free of cost. If you are a student/researcher you must know about this. Library Genesis :  This is another great website for students. This website provide books for free. http://Scholar.google.com : This is another type of search engine created by Google, students can search on it for school related stuff and find good results, there are also articles available there. Unpaywall :  This amazing extension provides all the papers you need to read, for FREE! Available for Chrome and FireFox http://www.gutenberg.org   :  50000 free ebooks to download (epub, kindle, android, ipad) Old versions of Windows, Mac and Linux Software, Apps & Abandonware Games - Download at OldVersion.com If you update or upgrade any software and if you don't like it; then you can downgrade

Check if the String is Palindrome (C++ & Java Program)

Image
A palindrome string means the reverse of string is equal to the original string.  C++ Program #include <iostream> #include <algorithm> #include <string> bool isPalindrome(const std::string& str) {    std::string temp(str);    std::transform(temp.begin(), temp.end(), temp.begin(), ::tolower);    return temp == std::string(temp.rbegin(), temp.rend()); } int main() {   std::string word;   std::cout << "Enter the String \n";   std::getline(std::cin, word);   if(isPalindrome(word))     std::cout << "The string " << word << " is palindrome \n";   else     std::cout << "The string " << word << " is not palindrome \n";   return 0; }   We have written #include <algorithm> beacuse we are using transform function which is in the Standard Template Library: Algorithm. You can know more about Transform from C++ STL ...

C++ STL : An example of Transform Algorithm

#include <iostream> #include <algorithm> #include <list> double reciprocal(double i){   return 1.0/i;   } int main() {     std::list<double> vals;     int i;     for(i=1; i<10; i++) vals.push_back((double)i);     std::cout << "Original contents of vals:\n";     std::list<double>::iterator p = vals.begin();     while(p != vals.end()) {     std::cout << *p << " ";     p++; }    std::cout << std::endl;
For more Computer Science, Linux, C++ content visit ProgrammerCave
Follow us on Facebook | Instagram | Telegram

Contribute on Paypal