Ad Code

cs201 assignment 2 solution 2021





 #include <iostream>

using namespace std;

int main()

{

char n[] = {'M','u','s','s','a','\0'};

char id[] = {'B','C','2','0','2','3','4','5','3','5'};

cout<<"My first Name: "<<n<<endl;

cout<<"My VUID: "<<id<<endl;

cout<<"Last digit of my VUID: "<<id[9]<<endl<<endl;

int x=1; 

int sum=0;

int j=1;

for(x;x<=4;x++){

if(n[x]=='a'||n[x]=='e'||n[x]=='i'||n[x]=='o'||n[x]=='u' || n[x]=='A' || n[x]=='E' || n[x]=='I' || n[x]=='O' || n[x]=='U'){

cout<<"\nvowel no"<<j<<": "<<n[x];

sum++;

j++;

}

}

cout<<"\n\nTotal Vowels in my first name: "<<sum;

int sumVD=0;

int id1=id[9]-48;

sumVD=id1+sum;

cout<<"\nSum of Vowels in first name and last digits of VUID: "<<sumVD<<endl<<endl;

if(sumVD%2==0)

{

int l;

for(l=1;l<=sumVD;l++)

{

cout<<"Iteration No. "<<l<<endl;

cout<<"My first name is Musa"<<endl;

}

}

else if(sumVD%2!=0)

{

int l;

for(l=1;l<=sumVD;l++)

{

cout<<"Iteration No. "<<l<<endl;

cout<<"My last name is Jutt"<<endl;

}

}

return 0;

}

Post a Comment

0 Comments

Close Menu