Assignment#2
Assignment#2
Assignment#2
PROGRAMMING
COURCE CODE#CSC141
ASSIGNMENT#2
SUBMITTED TO: SIR NASIR MEHDI
int main()
int n,i,f;
cin>>n;
for(i=1;i<n; i++)
if(n%i==0)
f=i;
return 0;
OUTPUT:
INTRO TO COMPUTER PROGRAMMING
#include<iostream>
int main()
int size;
cin>>size;
int z=1;
{
INTRO TO COMPUTER PROGRAMMING
for (int j=size; j>i; j--)
if ( i>0)
cout<<" ";
z+=2;
cout<<"*";
z-=4;
{
INTRO TO COMPUTER PROGRAMMING
cout<<" ";
cout<<"*";
cout<<" ";
z-=2;
if (i!=size-1)
cout<<"*";
cout<<endl;
system("pause");
return 0;
OUTPUT:
INTRO TO COMPUTER PROGRAMMING
1 2 3 4 5 6
------
1 2 3 4 5 6
2 4 6 8 10 12
3 6 9 13 15 18
4 8 12 16 20 24
5 10 15 20 25 30
6 12 18 24 30 36
#include<iostream>
int n,i,j;
cin>>n;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
cout<<i*j<<" ";
} cout<<endl;
cout<<endl;
return 0;
OUTPUT:
INTRO TO COMPUTER PROGRAMMING
4. Write C++ programs that Display the sum of the digits of a given
number. User gives a number. For example.435 and its sum=12.
#include<iostream>
INTRO TO COMPUTER PROGRAMMING
using namespace std;
int main()
{
int val, num, sum = 0;
system("pause");
return 0;
}
OUTPUT:
INTRO TO COMPUTER PROGRAMMING