0% found this document useful (0 votes)
91 views9 pages

Computer Programming Assigment 1 - CSL-110 - Bahria University

This document contains 5 programming assignments completed by Wasif Hassan Niazi with student ID 02-235221-012. The first assignment collects and displays personal information such as name, age, address from the user. The second assignment performs basic mathematical operations like addition, subtraction, multiplication and division on two numbers. The third assignment checks the status of an employee as senior or junior and displays the appropriate salary. The fourth assignment prints and sums all odd numbers from 1 to a user-input number. The fifth assignment calculates and displays the sum of squares of numbers from 1 to a user-input number.

Uploaded by

Wasif Hassan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views9 pages

Computer Programming Assigment 1 - CSL-110 - Bahria University

This document contains 5 programming assignments completed by Wasif Hassan Niazi with student ID 02-235221-012. The first assignment collects and displays personal information such as name, age, address from the user. The second assignment performs basic mathematical operations like addition, subtraction, multiplication and division on two numbers. The third assignment checks the status of an employee as senior or junior and displays the appropriate salary. The fourth assignment prints and sums all odd numbers from 1 to a user-input number. The fifth assignment calculates and displays the sum of squares of numbers from 1 to a user-input number.

Uploaded by

Wasif Hassan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Wasif Hassan Niazi

02-235221-012

Computer Programming Assignment 1

Name: Wasif Hassan Niazi


BSIT – 1A
Enroll No: 02-235221-012
Wasif Hassan Niazi

02-235221-012

Question 1:
#include <iostream> cout<<"Enter Your NIC number ";

using namespace std; cin>> id;

int main() cout<<"Enter Your Phone NO ";

{ cin>>p;

char n[30],fn[30], cn [50], c[50],ad[100]; cout<<"Enter Your Address ";

int a,p,id; cin>>ad;

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

cin>>n; cout<<"Your Name is "<<n<<endl;

cout<<"Enter Your age "; cout<<"Your Age is "<<a<<endl;

cin>>a; cout<<"Your Father's name is "<<fn<<endl;

cout<< "father’s name" ; cout<<"Your college name is " <<cn<< endl;

cin>> fn; cout<<"Your City is "<<c<<endl;

cout<<"Enter Your College name "; cout<<"Your NIC ID is "<<id<<endl;

cin>> cn; cout<<"Your Phone No is "<<p<<endl;

cout<<"Enter Your City "; cout<<"Your Address is "<<ad<<endl;

cin>>c; }
Wasif Hassan Niazi

02-235221-012

Question 2:
#include <iostream>
using namespace std;

int main()
{
int a, b;
a = 10;
b = 2;
cout << "a = 10 " << " --- " << " b = 2" << endl;

cout << "_______________________" <<endl;


cout <<endl<<endl;
cout << "a + b = " << (a + b) << endl;
Wasif Hassan Niazi

02-235221-012

cout << "a - b = " << (a - b) << endl;

cout << "a * b = " << (a * b) << endl;

cout << "a / b = " << (a / b) << endl;

cout << "a % b = " << (a % b) << endl;

return 0;
}
Wasif Hassan Niazi

02-235221-012

Question 3:

#include<iostream>

#include<conio.h>

using namespace std;

int main()

char status;

int senior=400,junior=275;

cout<<"S and s is for senior person salary\n";

cout<<"J and j is for junior person's salary\n";

cout<<"enter status:";

cin>>status;

if(status=='S'|| status=='s')

cout<<"Senior person salary is $."<<senior;

else if(status=='J'||status=='j')

cout<<"Junior person salary is $."<<junior;

else

cout<<"you should select senior or junior, please try again ";

getch();

}
Wasif Hassan Niazi

02-235221-012

Question 4
#include <iostream>

using namespace std;

int main()

int i=1;

int n,add=0;

cout << "print all odd number from 1 to n :";

cin >>n;

for(i=1;i<=n;i++)

if (i%2!=0)

cout <<i<<endl;

add=add+i;

cout << "The addition of odd number are "<<add;

return 0;

}
Wasif Hassan Niazi

02-235221-012
Wasif Hassan Niazi

02-235221-012

Question 5

#include <iostream>

using namespace std;

int main()

int num1;

int sum_sq;

cout << "Enter a number greater than 0 (less than 1 to quit): ";

cin >> num1;

while (num1 >= 1)

sum_sq = 0;

for (int i = 1; i<= num1; i++)

sum_sq += i * i;

cout << "The total sum of the squares from 1 to " << num1 << " is " << sum_sq << endl;

cout << "Enter a number greater than 0 (less than 1 to quit): ";

cin >> num1;

system("pause");

return 0;

}
Wasif Hassan Niazi

02-235221-012

You might also like