Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Join to our Telegram Channel to notify you all new latest update. Click Here
  • Claim Your Free Certified Membership Click here

C++

nelnel

Elite Poster
Joined
Aug 31, 2022
Messages
186
Reaction score
29
Points
28
baka meron po kayong mga C++ example program or kahit anong C++ kase C++ language po ang gamit namin sa school
 
baka meron po kayong mga C++ example program or kahit anong C++ kase C++ language po ang gamit namin sa school

C++ "Hello World!" Program​


C++:
// Your First C++ Program

#include <iostream>

int main() {
    std::cout << "Hello World!";
    return 0;
}
 

Example: Store Information in Structure and Display it​

C++:
#include <iostream>
using namespace std;

struct student
{
    char name[50];
    int roll;
    float marks;
} s[10];

int main()
{
    cout << "Enter information of students: " << endl;

    // storing information
    for(int i = 0; i < 10; ++i)
    {
        s[i].roll = i+1;
        cout << "For roll number" << s[i].roll << "," << endl;

        cout << "Enter name: ";
        cin >> s[i].name;

        cout << "Enter marks: ";
        cin >> s[i].marks;

        cout << endl;
    }

    cout << "Displaying Information: " << endl;

    // Displaying information
    for(int i = 0; i < 10; ++i)
    {
        cout << "\nRoll number: " << i+1 << endl;
        cout << "Name: " << s[i].name << endl;
        cout << "Marks: " << s[i].marks << endl;
    }

    return 0;
}

output
Code:
Enter information of students:

For roll number1,
Enter name: Tom
Enter marks: 98

For roll number2,
Enter name: Jerry
Enter marks: 89
.
.
.
Displaying Information:

Roll number: 1
Name: Tom
Marks: 98
.
.
.
 
Spamming or posting low-quality replies like "asdasd", "thankssss", "tyyy" automatically account restriction or permanent ban.
Changing Account info, password or being selfish will cause an automatic permanent ban without prior notice be nice and let everyone use the valuable stuff here in the community.
Feedback on the post is a big help to improve and make the member more willing to contribute.

NEW TOPICS

Back
Top