Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

NATIONAL UNIVERSITY OF MODERN LANGUAGES (NUML)

ASSIGNMENT # 1

SUBMITTED TO : SIR TALAL BIN AFZAL

SUBMITTED BY : M.ABUBAKER

DATE: 22-03-2021

QUESTION 1.

Declare the header files. Then define the main function. Then use the
cout statement to print the required message.

#include <iostream>

#include <stdio.h> //standard input/output function

using namespace std;


int main()

{cout<<"Hello world";

return 0;

QUESTION 2.
Write a Program To Assign Values To Different Variables (Atleast One
Value For Each Variable Type).At The Time Of Declaration. Print The
Assigned Values On The Computer Screen.
#include <iostream>

using namespace std;

int main ()

int num =38;

float decimal = 4.9;

double decimal2 = 3445.9;

char alphabet ='t';

string message = "Hello";


cout << "int: " <<num<<endl;

cout << "float: " <<decimal<<endl; cout << "double: " <<decimal2<<endl;
cout << "character: " <<alphabet<<endl; cout << "string: " <<message<<endl;

return 0;

QUESTION 3.
Write a program to perform arithematic operation by using all
arthematic operators. Also print result on the screen.

#include <iostream>

using namespace std;

int main()

{
int a=90;

int b=60;

int c=40;

int d=20;

float q,w,e,r,t,y,u,i,o,p,m,s;

q=c+b;

w=d-b;

e=a*c;

r=b/c;

t=++d;

y=--c;

u=d%c;

i=b+=a;

o=a-=d;

p=b/=c;

m=a*=d;

s=c%=b;

cout<<"addition: "<<q<<endl;

cout<<"subtraction: "<<w<<endl;

cout<<"multiplication: "<<e<<endl;

cout<<"division: "<<r<<endl;
cout<<"increment"<<t<<endl;

cout<<"decrement"<<y<<endl;

cout<<"percentage: "<<u<<endl<<endl;

cout<<"other operator 1: "<<i<<endl;

cout<<" other operator 2: "<<o<<endl;

cout<<" other operator 3: "<<p<<endl;

cout<<" other operator 4: "<<m<<endl;

cout<<" other operator 5: "<<s<<endl;

return 0;

}
QUESTION 4.
Write a program that calculate area and circumference
of circle(using pi as a floating constant) with the output
formatted in the following way
#include <iostream>

using namespace std;

#define pi 3.14

int main()

float a,cir,radius;

cout<<"radius is";

cin>>radius;

a=pi*radius*radius;

cir=2*pi*radius;

cout<<"area is"<<a<<endl<<"circumference is"<<cir;

return 0;

}
QUESTION 5.
Write a program to assign two variables by assignment
statement interchange the values and print the result on
screen.

#include <iostream>

using namespace std;

int main ()

int x=50,y=34,temp;

cout<<"x="<<x<<"\ny="<<y;

temp=x;

x=y;

y=temp;

cout<<"\ny="<<y<<"\nx="<<x;

return 0;

You might also like