Assignment no 1
Task 1:
#include<iostream>
using namespace std;
int main()
int a1, a2, a3, difference_a ,sum_a ,average_a;
cout<<"enter numbers obtained in a1 = "<<endl;
cin>>a1;
cout<<"enter numbers obtained in a2 = "<<endl;
cin>>a2;
difference_a=a1-a2;
if(a1<60){
cout<<" a1 is failed"<<endl;
Else
cout<<" a1 is passed"<<endl;}
if(a2<60){
cout<<" a2 is failed"<<endl;
else
cout<<" a2 is passed"<<endl;
sum_a=a1+a2;
cout<<" total numbers = "<<sum_a<<endl;
average_a = sum_a/2;
Assignment no 1
cout<<" average marks = "<<average_a<<endl;
return 0;
Task 02:
#include<iostream>
using namespace std;
int main()
int xy_marks[5] ,ave;
xy_marks[0]=10;
xy_marks[1]=20;
xy_marks[2]=30;
cout<<"enter marks of quiz 4"<<endl;
cin>>xy_marks[3];
cout<<"enter marks of quiz 5"<<endl;
cin>>xy_marks[4];
int sum =xy_marks[0] + xy_marks[1] + xy_marks[2] + xy_marks[3] + xy_marks[4];
ave =sum/5;
cout<<xy_marks[0]<<" , "<<xy_marks[1]<<" , "<<xy_marks[2]<<" , "<<xy_marks[3]<<" ,
"<<xy_marks[4]<<endl;
cout<<" total marks are : "<<sum<<endl;
cout<<" average are : "<<ave<<endl;
double per=sum*100/50;
cout<<"Percentage or marks is : "<<per<<endl;
if(per<50){cout<<"you are fail!"<<endl;
}else{cout<<"you are pass."<<endl;
int r;
Assignment no 1
cout<<"quiz you want to check !"<<endl;
cin>>r;
// cout<<xy_marks[r];
if(r==1){cout<<xy_marks[0]<<endl;
else if(r==2){cout<<xy_marks[1]<<endl;
else if(r==3){cout<<xy_marks[2]<<endl;
else if(r==4){cout<<xy_marks[3]<<endl;
else if(r==5){cout<<xy_marks[4]<<endl;
else{cout<<"error"<<endl;
return 0;
TASK_03:
#include<iostream>
using namespace std;
int main()
{ int Q;
cout<<"enter quiz’s u want to check; ";
cin>>Q;
int Q_marks[Quiz];
for (int j=0; j<Q; j++)
Assignment no 1
{
cout<<"enter marks of quiz no : "<<j+1<<" = ";
cin>>Q_marks[j];
int r;
cout<<"enter quiz no u want to check: ";
cin>>r;
cout<<"marks of quiz no " <<r<<" are "<<Q_marks[r]<<endl;
if ( Q_marks[r]>=50){cout<<"you are pass in that quiz ...";
else{cout<<"you are fail in that quiz ...";
return 0;
Task 04:
#include<iostream>
using namespace std;
int main()
{ int Qz;
cout<<"enter quizes u want to check; ";
cin>>Quiz;
int Qz_marks[Qz];
for(int j=0; j<Qz; j++)
cout<<"enter marks of quiz no : "<<j+1<<" = ";
cin>>Qz_marks[j];
Assignment no 1
}
int passcount=0;
int failcount=0;
for(int i=0; i<Qz; i++){
if(Qz_marks[i]>=60){
passcount++;}
else{
failcount++;
cout<<"u are pass "<<passcount<<" quizes "<<endl;
cout<<"u are fail "<<failcount<<" quizes .";
return0;
Task 05:
#include <iostream>
#include <string>
using namespace std;
string Mypassword;
int password_length;
int main() {
cout<<" your password contains atleast one capital and small letter \n\n\n";
Assignment no 1
cout << "create new password : ";
getline(cin, Mypassword);
password_length = Mypassword.size();
cout << endl << " entered password is: " << Mypassword << endl;
cout << "Length of password is: " << password_length << endl;
int capitalcount = 0;
int smallcount = 0;
for (int i = 0; i < password_length; i++) {
char ch = Mypassword[i];
if (ch>=65 && ch<=90) {
capitalcount++;
} else if (ch>=97 && ch<=122) {
smallcount++;
cout << "Number of capital letters are: " << capitalcount << endl;
cout << "Number of small letters are: " << smallcount << endl<<endl;
if (capitalcount > 0 && smallcount > 0) {
if (password_length >=5 && password_length <= 15)
cout << "password accepted" << endl;
} else {
cout << "Re-enter password " << endl;
} else {
Assignment no 1
cout << "ERROR! !!!" << endl;
return 0;
Task 06:
#include<iostream>
#include<string>
using namespace std;
string Mypw;
int pw_length ;
int main()
{ // for making code attractive
cout<<"\n";
cout<<" password contain one capital letter \n";
cout<<" password contain atleast one uppercase and symbol \n\n\n";
cout<<"create new password _ ";
getline(cin,Mypw);
pw_length=Mypw.size();
cout<<endl<<"Your entered password is _ "<<Mypw<<endl;
cout<<endl<<"Length of your password is _ "<<pw_length<<endl;
int capitalcount =0;
int smallcount=0;
int digitcount=0;
Assignment no 1
int sPcount=0;
for (int i=0; i<pw_length; i++){
char ch = Mypw[i];
if (ch>=65 && ch<=90) {
capitalcount++;
} else if (ch>=97 && ch<=122) {
smallcount++;
}else if (ch>='0' && ch<='9') {
digitcount++;
else
sPcount ++;
cout<<"Numbers of capital letters are _ "<<capitalcount<<endl;
cout<<"Numbers of small letters are _ "<<smallcount<<endl;
cout << "No of special letters is_ "<< sPcount <<endl;
cout << "No of numeric characters is_ "<< digitcount <<endl;
if (capitalcount> 0 && smallcount> 0&&sPcount>0&&digitcount>0){
cout<< "password accepted "<<endl;
} else{
cout<< "Re-enter"<<endl;
}
Assignment no 1