Here is a link to some C++ Code that I did while I was in college. Thought I would post it because maybe it will help someone else.

[url]

:D

Dani AI

Generated

's 2005 post links to a compact set of college-era C++ examples that still have teaching value. 's suggestion to add those snippets to the site library was sound—searchability and consistent formatting help long-term reuse. Later replies in this thread (notably and ) show common beginner requests; the thread was eventually closed by . The examples are useful but benefit from small modernizations before reuse.

Practical modernization notes: compile old samples with a current standard (for example, g++ -std=c++17 -Wall -Wextra), replace deprecated headers/idioms with standard containers and RAII (std::vector, std::string), and prefer algorithms (std::min_element) over raw loops where clear. Always add basic input validation, watch signed/unsigned comparisons and overflow, and pick a wider integer type (long long) if values might be large. Also verify any reuse against the original author's license.

A minimal, focused example that follows the homework prompt from (first value is the count; the count itself is not one of the values to compare):

#include <iostream>
#include <limits>

int main() {
    int count;
    if (!(std::cin >> count)) return 0;       // no input
    if (count <= 0) {
        std::cout << "No numbers to compare\n";
        return 0;
    }

    int smallest = std::numeric_limits<int>::max();
    for (int i = 0; i < count; ++i) {
        int value;
        if (!(std::cin >> value)) break;
        if (value < smallest) smallest = value;
    }

    if (smallest == std::numeric_limits<int>::max())
        std::cout << "No valid integers read\n";
    else
        std::cout << smallest << '\n';

    return 0;
}

Notes: with input "5 10 3 4 2 8" this prints "2". The snippet is intentionally minimal—reflecting 's point about homework policy—so study the pattern (read count, iterate, maintain running minimum) rather than simply copying. For production, add stronger error handling, unit tests, and consider reading until EOF if the count is unspecified.

Recommended Answers

All 13 Replies

Thank you :) I noticed you posted some of your code over in our code snippets forum. If you would be able to post all of your code in our library, I woudl be most appreciative! This way it's all searchabl, and properly color coded and indented for our membes to find and peruse :) If not, that's okay too. Welcome to our community.

Thank you :) I noticed you posted some of your code over in our code snippets forum. If you would be able to post all of your code in our library, I woudl be most appreciative! This way it's all searchabl, and properly color coded and indented for our membes to find and peruse :) If not, that's okay too. Welcome to our community.

No problem. I'll try to post all the coding from my site along with other coding I still have on my PC.

:)

Wow! I really appreciate that - as I'm sure do many other members of the community. I hope you enjoy your stay here.

Member Avatar for Member #27895

Nice collection. :)

write a program that uses a for statement to find the smallest of several integers. Assume that the first value read specifies the number of values remaining and the first number is not one of the intergers to compare.pls help me i need it now!

write a program that uses a for statement to find the smallest of several integers. Assume that the first value read specifies the number of values remaining and the first number is not one of the intergers to compare.pls help me i need it now!

Done Sir - but I cannot post it at the forum, it is against the forum rule to do others homework.

Here is a link to some C++ Code that I did while I was in college. Thought I would post it because maybe it will help someone else.

http://www.vsbrown.com/cplusplus.asp


:D

Great collection,definately beneficial for some of the beginners,required any help please do feel free.:)

i need code for DVd rental system.. i am new in this field..huwawawa!! someone, plz help me!

hahaha...nice beat ones????

:*
hi...can i sak you !? some question....???

Can you give me some C++ code example.. simple code..

Too many "give me da codezz" replies/bumps in this thread.
Closed

i need Some Codes For books shop system
specially for delete books detail , edit , billing section
and if they have administator
for him that delete function codes ??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.