Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

LAHORE COLLEGE FOR WOMEN AND UNIVERSITY

NAME: SABOOH HAROON BUTT

SECTION: BSCS SECTION (A)EVENING

ASSIGNMENT: PROGRAMMING FUNDAMENTAL

SUBJECT TEACHER: MA’AM FARIA


Programming fundamental

1.Writ a program to solve the following equation a*b/(-c*31%13)*d


#include<iostream.h>

Void main()

Int a,b,c,d,formula;

Cout<<”enter the values of a,b,c,d”;

Cin>>a>>b>>c>>d;

Formula=a*b/(-c*31%13)*d

Cout<<”the formula is <<formula,f;

2. Write a program that display the sizes of different data types like char,int,..

#include<iostream.h>

Void main()

Cout<<”size of int”<<sizeof(int);

Cout<<size of float”<<sizeof(float);

Cout<<”size of char”<<sizeof(char);

Cout<<”size of double”<<sizeof(double);

}
3. Write a program that input salary and grade. It adds 50%bonus if the grade is
greater than 15. It adds 25%.....

#include<iostream.h>

Void main()

Int salary, grade, greater, less,bonus,total;

Cout<<”enter the values of salary, grade”;

Cin>>grade>>salary;

If(grade>15)

Bonus=salary/2;

Total=salary + bonus;

Cout<<”total salary is”<<total;

Else(grade>=15)

Bonus=salary/4;

Total=salary+bonus;

Cout<<”total salary is” <<total;

}}

4. Write a program that display either the number entered is a even or odd…

#include<iostream.h>

Void main()

{
Int num1;

Cout<<”enter the value”;

Cin>>num1;

Num=num1%2==0? Cout<<”the number is even”: cout<<”the number is odd”;

5. Write a program that input are even odd number, multiply the even number…

#include<iostream.h>

Void main()

Int even, odd, multiply1,multiply2, add, subtract;

Cout<<”enter the even number”;

Cin>>even;

Cout<<”enter the odd number”;

Cin>>odd;

Multiply1=even +5;

Multiply2=odd+7;

Add= multiply1+mulyiply2;

Subtract= add-1000;

Cout<<”the result will be:”<<subtract;

6. Write a program which takes five number…..

#include<iostream.h>

Void main()

{
Int num1,num2,num3,num4,num5,greatest,smallest;

Cout<<”enter the values:”;

Cin>>num1>>num2>>num3>>num4>>num5>>;

if(num1>greatest)

Cout<<greatest=num1;

If(num2>greatest)

Cout<<greatest=num2;

If(num3>greatest)

Cout<<greatest=num=3;

If(num4>greatest)

Cout<<greatest=num4;

If(num5>greatest)

Cout<<greatest=num5;

If(num1<smallest)

Cout<<smallest=num1;

If(num2<smallest)

Cout<<smallest=num2;

If(num3<smallest)

Cout<<smallest=num3;

If(num4<smallest)

Cout<<smallest=num4;

If(num5<smallest)

Cout<<smallest=num5;

Cout<<”the smallest num is:”<<smallest;


Cout<<”the greatest num is :”<<greatest;

7. Write a program that display first ten number with their square while loop

#include<iostream.h>

Void main()

Int i=1;

While(i<=10)

Cout<<”i/t i /t/n”,i,i*i;

i=i++;

8. Write a program that display the product of all odd number from 1 to 10 using
for loop

#include<iostream.h>

Void main()

Int product,i;

For(i=1; i<=10;i+=2)

Cout<<”enter the number”;

Product=product*I;

Cout<<”result=”<<product;
}

9. Write a program which take starting and ending numbers and then print the odd
number ranges in those numbers

Int i, j;

Cout<<’”enter the starting number , i”;

Cout<<”enter the ending number,j “;

Cin>>I;

Cin>>j;

Do

If(i%2!=0)

Cout<<”the odd number is “;

I=i++;

While(i<=j)

10. Write a program that display this output

*****

*****

*****

*****

*****

#include<iostream.h>

Void main()
{

Int i,j;

For(i=1; i<=5; i++)

For(j=1; j>=5; j++)

Cout<<”*”;

Cout<<”/t”;

11. Write a program that print the following output

12345

12 3 4

123

12

#include<iostream.h>

Void main()

Int I,j;

For(i=5; i>=1; i--)

For(j=1;j<=I; j++)

Cout<<j;
}

Cout<<”/t”;

12. Write a program that display the following output

4444

333

22

#include<iostream.h>

Void main()

{ int I,j;

For(i=4; i>=1; i--)

For(j=1;j<=I;j++)

Cout<<”j”;

Cout<<”/t”;

13. Write a program that display the possible combination of 1 2 3

#include<iostream.h>

Void main()
{

Int I,j,k;

For(i=1; i<=3;i++)

For(j=1;j<=3;j++)

For(k=1;k<=3

{cout<<i<<j<<k;

Cout<<”/t”;

14. Write a program that input and display the factorial of that number using while
loop

#include<iostream.h>

Void main()

Int n;

Int i=1, p=1;

Cout<<”enter the number:”;

Cin>>n;

While(c<=n)
{

P=p*c;

C++;

Cout<<”fact of n:”<<p;

You might also like