GROUP 5 C++ Assignemt

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Mattu University

College Of Computer Science and Engineering


Department Computer Science
Computer Programming II
Course code: CoSc 2012

Group Assignment
Name Id RU/14

1. KIYATOLI ABDULJELIL 1587


2. LALISE ASFAW 1620
3. WARIS HAILU 2613
4. TESFAY ARERI 2496
5. TOLERA YADETA 4759
6. ZERESENY HAILU 10019
7. ANTENEH TESFAYE 5199
8. KEDIR TEKA 1553
9. KENATE WAGARI 1535

Submitted to:Haimanot T.

Submitted date:May 19/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;

int main(){

int mat[3][2], i, j, mat2[3]={0};

cout<<"Enter Elements of Matrix: ";

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

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

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

cin>>mat[i][j]; }

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

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

mat2[i]+=mat[i][j]; }

cout<<"\nAdding the Two Given Matrix...\n";

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

cout<< " Row " <<i+1<<":"<<mat2[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 has.
#include<iostream>

#include<string>

using namespace std;

int main (){

int numofvowels=0;

string userstring="";

cout<< " Enter Your Name " <<endl;

getline(cin,userstring);

for (int i=0;i<userstring.length();i++){

if((userstring[i]==('a'))||(userstring[i]==('e'))||(userstring[i]==('i'))||(userstring[i]==('o'))||
(userstring[i]==('u')) )

numofvowels=numofvowels+1;}

cout<<numofvowels<<endl;

return 0;

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

#include <iostream>

#include <string.h>

using namespace std;

int main() {

char str[100], temp;

int i, j, k, len;

cout << "Enter a string \n";

cin.getline(str,100);
len = strlen(str);

for(i = 0, j =0; i < len; i++) {

if(str[i]==' ' || i == len-1){

if(i < len-1) {

k = i - 1; }

else {

k = i;

while (k > j) {

temp = str[j];

str[j] = str[k];

str[k] = temp;

j++;

k--;

j = i + 1;

cout << str;

return 0;

You might also like