0% found this document useful (0 votes)
13 views10 pages

IICT - Assignment 4

Uploaded by

magmaborax
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)
13 views10 pages

IICT - Assignment 4

Uploaded by

magmaborax
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/ 10

IICT Assignment #04

Arooj Fatima --70146483

C++ Programs
submitted to : Sir Hamedoon
1. Display Name :

CODE :>

#include <iostream>
Using namespace std;
Int main(){
String name;
Cout<<”Enter your name”;
Cin>>name;
Cout<<”Welcome “<<name;
Return 0;
}

2. Number x2 :

CODE :>

#include <iostream>
Using namespace std;
Int main(){
Int number;
Cout<<”Enter a number : “;
Cin>>number;
Cout<<”The double of “<<number<<” is : “<<number*2;
Return 0;
}
3. Addition 3 nums :

CODE :>

#include <iostream>
Using namespace std;
Int main(){
Int a, b, c;
Cout<<”Enter 1st number :”; cin>>a;
Cout<<”Enter 2nd number :”; cin>>b;
Cout<<”Enter 3rd number :”; cin>>c;
Cout<<”\n Sum of all 3 numbers is : “<<a+b+c;
Return 0;
}

4. Arithmetic ops :

CODE :>

#include <iostream>
Using namespace std;
Int main(){
Int a, b;
Cout<<”Enter 1st number :”; cin>>a;
Cout<<”Enter 2nd number :”; cin>>b;
Cout<<”\n Sum of numbers is : “<<a+b;
Cout<<”\n Difference of numbers is : “<<a-b;
Cout<<”\n Product of numbers is : “<<a*b;
Cout<<”\n Division of numbers is : “<<a/b;
Cout<<”\n Modulus of numbers is : “<<a%b;

Return 0;
}

5. Add and multiply 3 nums :

CODE :>

#include <iostream>
Using namespace std;
Int main(){
Int a, b, c;
Cout<<”Enter 1st number :”; cin>>a;
Cout<<”Enter 2nd number :”; cin>>b;
Cout<<”Enter 3rd number :”; cin>>c;
Cout<<”\n Sum of all 3 numbers is : “<<a+b+c;
Cout<<”\n Product of all 3 numbers is : “<<a*b*c;

Return 0;
}

6. Relational ops:
CODE :>

#include <iostream>
Using namespace std;
Int main(){
Int a, b;
Cout<<”Enter 1st num : ‘’; cin>>a;
Cout<<”Enter 2nd num:”; cin>>b;
If(a>b)
Cout<<”a is greater than b”;
Else if (a<b)
Cout<<”b is greater than a”;
Else
Cout<<”a and b are equals”;
Return 0;
}

7. Swaping Variables :

CODE :>

#include <iostream>
Using namespace std;
Int main(){
Int a, b, temp;
Cout<<”Enter value of a : “; cin>>a;
Cout<<”Enter value of b : “; cin>>b;
Temp=a;
a=b;
b=temp;
cout<<”Values after swap are a : “<<a<<” and b: “<<b;
Return 0;
}

8. Name and age in months:

CODE :>

#include <iostream>
Using namespace std;
Int main(){
String name;
Int age;
Cout<<”Enter name : “; cin>>name;
Cout<<”Enter age: “; cin>>age;
Cout<<”The age of “<<name<<” in months is “<<age*12;
Return 0;
}

9. Total and avg marks :

CODE :>
#include <iostream>
Using namespace std;
Int main(){
String name;
Int marks1, marks2, marks3;
Cout<<”Enter your name”;
Cin>>name;
Cout<<”Marks of Subject 1 : “; cin>>marks1;
Cout<<”Marks of Subject 2 : “; cin>>marks2;
Cout<<”Marks of Subject 3 : “; cin>>marks3;
Cout<<”Welcome “<<name;
Cout<<”Average marks are : ”<<(marks1+marks2+marks3)/3;
Cout<<”Total marks are : ”<<(marks1+marks2+marks3);

Return 0;
}

10.Times table :

CODE :>

#include <iostream>
Using namespace std;
Int main(){
Int num;
Cout<<”Enter a num: “; cin>>num;
For(int i=0; i<=10; i++)
{
Cout<<endl<<num<<” x “<<i<<” = “<<num*i;
}
Return 0;
}
FLOWCHARTS=>

You might also like