Professional Documents
Culture Documents
Asssinment 1
Asssinment 1
Assignment-01
You are required to write the C++ codes for the following tasks. Add suitable
comments in your code for better illustration.
Plagiarism will result in loss of grades.
Tasks:
• Task-01:
#include<iostream>
using namespace std;
int main (){
int a=8;
cout<<"a="<<a<<endl;
cout<<"enter the obtain marks in quiz number1"<<endl;
int d;
cin>>d;
cout<<"obtain marks in quiz number 1="<<d<<endl;
cout<<"enter the obtain marks in quiz number 2="<<endl;
int g;
cin>>g;
cout<<"obtain marks in quiz number 3="<<d<<endl;
int sum=a+d+g;
int y;
y=sum;
cout<<"total sum="<<y<<endl;
double avg=y/3;
cout<<"average of my marks ="<<avg<<endl;
}
Task-02:
#include <iostream>
using namespace std;
int main() {
int Qz_arry[4];
for (int i = 0; i <=4; i++) {
cout << "Enter marks for Quiz " << i + 1 << ": ";
cin >> Qz_arry[i];
}
int j;
for(int j=0;j<=4;j+1){
cout<<"enter the quiz the quiz number which who want see=";
int a;
cin>>a;
cout<<"your obtain marks in this quiz="<<Qz_arry[a]<<endl;
if(Qz_arry[a]>=5){
cout<<"your quiz passed";
}
else{
cout<<"sorry you are fail in this quiz";
}
}
return 0;
}
• Task-03:
#include <iostream>
using namespace std;
int main() {
int num_quizzes;
cout << "Enter the number of quizzes: ";
cin >> num_quizzes;
int Qz_arry[num_quizzes];
for (int i = 0; i <=num_quizzes; ++i) {
cout << "Enter marks for Quiz " << i + 1 << ": ";
cin >> Qz_arry[i];
}
int a;
cout << "Enter the quiz number you want to view: ";
cin >> a;
int main() {
int num_quizzes;
int countpass=0;
int countfail=0;
cout << "Enter the number of quizzes: ";
cin >> num_quizzes;
int Qz_arry[num_quizzes];
for (int i = 0; i <=num_quizzes; ++i) {
cout << "Enter marks for Quiz " << i + 1 << ": ";
cin >> Qz_arry[i];
}
for (int j = 0; j < num_quizzes+1; ++j) { // Initialize and fix loop condition
if (Qz_arry[j] >= 5) {
countpass++;
} else {
countfail++;
}
}
cout << "Your passed quizzes: " << countpass << endl;
cout << "Your failed quizzes: " << countfail << endl;
}
Task-05:
#include<iostream>
using namespace std;
int main(){
string mypw;
int pwlength;
cout<<"enter your password"<<endl;
cin>>mypw;
int capital=0;
int small=0;
int pwsize;
pwlength=mypw.size() ;
cout<<"your password length="<<pwlength<<endl;
for( int i=0;i<=pwlength;i++){
int main()
{