23 CS 05
23 CS 05
TO:
Sir Faheem
SMMITED BY:
MOAZ Bin
ZAFAR
(23-CS-05)
PROGRAMING FUNDAMENTAL
ASSIGNMENT#1
TASK#1
#include<iostream>
int main(){
int i,n,product;
cout<<"Enter number"<<endl;
cin>>n;
for(i=1;i<=10;i++){
product=n*i;
cout<<product<<" ";
cout<<"\n";
for(i=11;i<=20;i++){
product=n*i;
cout<<product<<" ";
cout<<"\n";
for(i=21;i<=30;i++){
product=n*i;
cout<<product<<" ";
}
Task#2
#include<iostream>
int main(){
cout<<"Enter number"<<endl;
int N1,N2,N3,a;
cout<<"Enter 3 number"<<endl;
cin>>N1>>N2>>N3;
if(N1%2==0){
cout<<N1<<" is even"<<endl;
}else{
cout<<N1<<" ODD"<<endl;
if(N2%2==0){
cout<<N2<<" is even"<<endl;
}else{
if(N3%2==0){
cout<<N3<<" is even"<<endl;
}else{
cout<<N3<<" ODD"<<endl;
if(N2<N1&&N1>N3){
cout<<"N1 is greater"<<endl;
}else if(N1<N2&&N2>N3){
cout<<"N2 is greater"<<endl;
}
else if(N2<N3&&N3>N1){
cout<<"N3 is greater";
Tsk#3
#include<iostream>
int main(){
int n,i,count=0;
cout<<"23-cs-5\n";
cout<<"Enter number"<<endl;
cin>>n;
for(i=2;i<n;i++){
if(n%i==0){
count++;
break;
}
}
if(count==0){
cout<<"prime";
}else{
cout<<"Composite";
return 0;
Task#4
#include<iostream>
fib_array[0] = 0;
fib_array[1] = 1;
cout << "Fibonacci Series up to " << n << ": "; for (int i = 0; i < n; i++) {
}
int main() { int n;
cout << "Enter the number of Fibonacci series elements: \n"; cin >> n;
if (n <= 0) {
cout << "Invalid input. Please enter a positive integer.\n" << endl; return 1;
Fibonacci(n); return 0;
Task#6
#include <iostream>
int main() {
int n;
cout << "Enter the number of rows for the pyramid: "<<endl;
cin >> n;
}
cout << endl;
return 0;}
Task#5
#include<iostream>
cout << "Enter the matrix elements:" << endl; for (int i = 0; i < rows; i++) {
cout << "Element at position (" << i + 1 << ", " << j + 1 << "): ";
}}}
for (int i = 0; i < rows1; i++) { for (int j = 0; j < cols2; j++) {
result[i][j] = 0;
}}}
cout << "Resultant Matrix:" << endl; for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++)
}}
int main() {
cout << "Enter dimensions of the first matrix (rows columns): ";
cout << "Enter dimensions of the second matrix (rows columns): ";
if (cols1 != rows2) {
cout << "Matrices cannot be multiplied. Number of columns in the first matrix should be equal to the
number of rows in the second matrix." << endl;
return 1;
return 0;
}}
Task#7
#include<iostream>
#include<algorithm>
int main() {
int n;
cin >> n;
if (n <= 0) {
int arr[n];
cout << "Enter the array elements:" << endl; for (int i = 0; i < n; i++) {
cout << "Maximum value: " << maxElement << endl; cout << "Minimum value: " << minElement <<
endl;
return 0;
Task#8
#include<iostream>
#include<string>
#include<cctype>
int numberScore = 0;
int specialCharScore = 0;
int upperCaseScore = 0;
int lowerCaseScore = 0;
if (isdigit(password[i])) {
numberScore = 2; break;
} }
if (!isalnum(password[i])) {
specialCharScore = 2; break;
} }
{ if
(isupper(password[i])) {
upperCaseScore = 2; break;
} }
if (islower(password[i])) {
lowerCaseScore = 2; break;
} }
return totalScore;
int main() {
string password;
cout<<"Moaz bin zafar 23-cs-05"<<endl; cout << "Enter your password: ";
getline(cin, password);
int strengthScore = checkstrength(password);
cout << "Password Strength Score: " << strengthScore << "/10" <<
endl;
--------------------------------------------------------------------------------------------------------------------