You are on page 1of 6

MATTU UNIVERSITY

COLLEGE OF ENGINEERING AND


TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE
ASSIGNMENT OF PROGRAMMING II
GROUP NAME ID

1. CHERINET ASRAT ------------------------ 0753


2. DURET JEMAL ------------------------ 0901
3. FIRDOS NEGA ---------------------------- 1140
4. GETACHEW ADUGNA -------------------1241
5. BELINA TEMSGEN ----------------------- 0753
6. AMANUEL TAFESE ---------------------- 4754
7. ELIAYAS GUDETA ----------------------- 0949
8. ELIAYAS ABDISA ------------------------ 0951
9. DEMEKU AMARE-------------------------0837

Submitted to .Haymanot.
1 . write a c++ code which that read 3x2 matrix and calculate
the sum of each row and store in one dimensional array
#include <iostream>

using namespace std;

int main() {

int matrix[3][2];

int row_sums[3];

for (int i = 0; i < 3; i++) {

for (int j = 0; j < 2; j++) {

cout << "Enter element (" << i+1 << "," << j+1 << "): ";

cin >> matrix[i][j];

for (int i = 0; i < 3; i++) {

int row_sum = 0;

for (int j = 0; j < 2; j++) {

row_sum += matrix[i][j];

row_sums[i] = row_sum;

cout << "The matrix is:" << endl;

for (int i = 0; i < 3; i++) {

for (int j = 0; j < 2; j++) {

cout << matrix[i][j] << " ";


}

cout << endl;

cout << "The sum of each row is:" << endl;

for (int i = 0; i < 3; i++) {

cout << row_sums[i] << " ";

cout << endl;

return 0;

2. Develop c++ program that accept the name of person then


count how many vowels the person have ?
#include <iostream>

#include <string>

using namespace std;

int main() {

string name;

int count = 0;

cout << "Enter name: ";

getline(cin, name);
for (int i = 0; i < name.length(); i++) {

char ch = tolower(name[i]);

if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {

count++;

cout << "Number of vowels in name: " << count;

return 0;

3.writedevelops a c++ code that accept the word from the user
and then display the word after reversing it ?
#include <iostream>

#include <string>

using namespace std;

int main() {

string word;

string reversed_word = "";

cout << "Enter word: ";

cin >> word;

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

reversed_word += word[i];

cout << "Reversed word: " << reversed_word;

return 0;

}
OUT PUT
1

You might also like