0% found this document useful (0 votes)
38 views2 pages

Doğuş C++ Week8 Programs

The document contains 3 C++ programs. The first program uses nested for loops to print a triangle pattern of increasing stars. The second program calculates the sum of terms of an alternating series using a for loop. The third program uses if-else statements to calculate income tax based on income amount.

Uploaded by

Yunus Çildan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views2 pages

Doğuş C++ Week8 Programs

The document contains 3 C++ programs. The first program uses nested for loops to print a triangle pattern of increasing stars. The second program calculates the sum of terms of an alternating series using a for loop. The third program uses if-else statements to calculate income tax based on income amount.

Uploaded by

Yunus Çildan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Question1

#include <iostream>
using namespace std;
int main()
{
int i,j,n, k;

cout<< "Please enter a number: "<< endl;


cin>> n;

for (i=1;i<=n;i++)
{
for (j=1; j <= n-i;j++)
cout << " ";
for ( k=1; k<=i; k++)
cout<< "*";
cout<<endl;
}
for (j=1; j<=n-i; j++)
{ cout<< "*";

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


cout<< " ";
}
cout<<endl;
return 0;

Question2
#include <iostream>
using namespace std;

int main()
{
int n,x,i,p=1;
double k1=2,k2=3,term,sum=0;
cout<<"Please enter n and x: ";
cin>>n>>x;

for(i=1;i<n; i++)
{ term=p*(k1*x/k2);
k1=k1+1;
k2=k2+5;
sum=sum+term;
p=-p;
}
cout<<sum;

return 0;

}
Question3

#include <iostream>
using namespace std;
int main()
{
double income_of_person,tax;

cout<<"Please enter the income of a person: ";


cin>> income_of_person;

if((income_of_person>0)&&(income_of_person<50000))
{
tax=income_of_person*0.10;
cout<<"The tax is "<<tax;
}
if ((income_of_person>50000)&& (income_of_person<100000))
{
tax= 50000*0.10+(income_of_person-50000)*0.12;

cout<< "The tax is "<<tax;


}

else
{ tax=50000*0.10+50000*0.12+(income_of_person-100000)*0.15;

cout<<"The tax is "<< tax << endl;


}
return 0;
}

You might also like