0% found this document useful (0 votes)
14 views4 pages

GROUP 3 C++ Assignemt

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views4 pages

GROUP 3 C++ Assignemt

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

MATTU UNIVERSITY

DEPARTMENT OF COMPUTER SCIENCE


COLLEGE OF ENGINEERING AND TECHNOLOGY
COURSE TITLE-COMPUTER PROGRAMMING II

GROUP ASSIGNMENT
GROUP MEMBERS NAME ID NUMBER

1.FIKADU ALEMU ------------------------------------------------------- 1119

2. GEMECHIS GEBEYEHU----------------------------------------------- 1214

3.KENBON BADHADHA ------------------------------------------------ 5200

4. HANA YEMANE ------------------------------------------------------ 1327

5. HIRKO MOTI --------------------------------------------------------- 4815

6. TABECH TAFASA ---------------------------------------------------- 2434

7. FEVEN SISAY---------------------------------------------------------- 1108

8.FALMATA DHABA------------------------------------------------------ 2496

Submitted to:- Ms. Hymanot

May, 2023
1. Write a program which reads a 3 x 2 matrix and then calculates the sum of each row and
store that in a one dimension array.

#include <iostream>

using namespace std;

const int ROWS = 3;

const int COLS = 2;

int main() {

int matrix[ROWS][COLS];

int rowSums[ROWS] = {0};

cout<<"Enter the elements of the matrix:\n";

for(int i = 0; i < ROWS; i++)

for (int j = 0; j < COLS; j++)

cout <<"Enter element at position(" <<i<<","<<j<< "):";

cin >>matrix[i][j];

for (int i = 0; i < ROWS; i++)

for (int j = 0; j < COLS; j++)

rowSums[i] += matrix[i][j];

cout <<"Sum of each row:\n";

for (int i = 0; i < ROWS; i++)

cout <<"Row " <<i + 1<<":"<<rowSums[i]<<endl;

return 0;

}
2. Develop a C++ program that accepts the name of a person and then counts how many
vowels the person's name have.

#include <iostream>

#include <string>

#include <cctype>

using namespace std;

int main() {

string name;

int vowelCount = 0;

int consonantCount = 0;

cout << "Enter a name: ";

getline(cin, name);

for (char ch : name) {

char lowercaseCh = tolower(ch);

if (isalpha(lowercaseCh)) {

if (lowercaseCh == 'a' || lowercaseCh == 'e' || lowercaseCh == 'i' || lowercaseCh =='o' ||


lowercaseCh == 'u') {

vowelCount++;

} else {

consonantCount++;

cout << "Number of vowels: " << vowelCount << endl;

cout << "Number of consonants: " << consonantCount << endl;

return 0;

}
3. Write a C++ program that accepts a word from the user and then displays the word after
reversing it.

#include <iostream>

#include <string>

using namespace std;

int main() {

string word;

cout << "Enter a word: ";

cin >> word;

string reversedWord;

for (int i = word.length() - 1; i >= 0; i--) {

reversedWord += word[i];

cout << "Reversed word: " << reversedWord << endl;

return 0;

You might also like