SlideShare a Scribd company logo
1 of 13
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
comscicomscicomscicomscicomscicomsci
PROJECT in COSC 60
Data Structure
Jenelyn B. Pañoso
BSCS II
SIMPLE PROGRAMS
 ARITHMETIC OPERATIONS 
CODES:
#include<iostream.h>
#include<conio.h>
main( )
{
clrscr( );
int n1, n2, a, s, m;
float d;
cout<<“Enter two integersn”;
cin>>n1;
cin>>n2;
a = n1 + n2;
s = n1 - n2;
m = n1 * n2;
d = n1 / (float)n2;
cout<<“nSumt = “<<a;
cout<<“nDifference = “<<s;
cout<<“nProductt = “<<m;
cout<<“nQoutient = “<<d;
getch( );
return 0;
}
OUTPUT:
 VOLUME OF CYLINDER 
CODES:
#include<iostream.h>
#include<conio.h>
#define Pi 3.1416
main( )
{
clrscr( );
float VOLUME,radius,height;
cout<<“This program will compute the
VOLUME of CYLINDER with an input of
height and radius.n”;
cout<<“Enter radius of CYLINDER: “;
cin>>radius;
cout<<“Enter height of CYLINDER: “;
cin>>height;
VOLUME = Pi*height*radius*radius;
cout<<“nVOLUME:”<<VOLUME;
getch( );
return 0;
}
OUTPUT:
 MASS 
CODES:
#include<iostream.h>
#include<conio.h>
main( )
{
clrscr( );
int a,b,c,gram;
float d,e,f;
cout<<“Enter GRAM: “;
cin>>gram;
a= 1000*gram;
b= 100*gram;
c= 10*gram;
d= 0.1*gram;
e= 0.01*gram;
f= 0.001*gram;
cout<<“Milligramt= “<<a;
cout<<“nCentigramt= “<<b;
cout<<“nDecigramt= “<<c;
cout<<“nDecagramt= “<<d;
cout<<“nHectogramt= “<<e;
cout<<“nKilogramt= “<<f;
getch( );
return 0;
}
OUTPUT:
 VOLUME OF A CONE 
CODES:
#include<iostream.h>
#include<conio.h>
#define Pi 3.1416
main( )
{
clrscr( );
float VOLUME,radius,height;
cout<<“This program will compute the
VOLUME of CONE with an input of height
and radius.n”;
cout<<“Enter radius of CONE: “;
cin>>radius;
cout<<“Enter height of CONE: “;
cin>>height;
VOLUME =
Pi*height*radius+Pi*radius*radius;
cout<<“nVOLUME:”<<VOLUME;
getch( );
return 0;
}
OUTPUT:
IF ELSE STATEMENT
 NEGATIVE OR POSITIVE 
CODES:
#include<iostream.h>
#include<conio.h>
main( )
{
clrscr( );
int n;
cout<<"Enter a number: ";
cin>>n;
if(n>=0)
cout<<"POSITIVE";
else
cout<<"NEGATIVE";
getch( );
return 0;
}
OUTPUT:
NESTED IF ELSE STATEMENT
 COMPARISON 
CODES:
#include <iostream.h>
#include <conio.h>
main( )
{
clrscr( );
int num1 , num2;
cout<<"Enter two numbers:n";
cin>>num1>>num2;
if (num1>num2)
cout<<num1<<" is greater than "<<num2;
else if (num1<num2)
cout<<num1<<" is less than "<<num2;
else if (num1==num2)
cout<<num1<<" is equal to "<<num2;
else
cout<<"INVALID INPUT";
getch( );
return 0;
}
OUTPUT:
SWITCH-CASE STATEMENT
 HOROSCOPE 
CODES:
#include<iostream.h>
#include<conio.h>
main( )
{
clrscr( );
int z;
cout<<"[1] t ARIES t March 21 - April
19n[2] t TAURUS t April 20 - May
20n[3] t GEMINI t May 21 - June
20n[4] t CANCER t June 21 - July
22n[5] t LEO t t July 23 - August 22
n[6] t VIRGO t t August 23 -
September 22n[7] t LIBRA t t
September 23 - October 22n[8] t
SCORPIO t October 23 - November
21n[9] t SAGITTARIUS t November 22
- December 21n[10] t CAPRICON t
December 22 - January 19n[11] t
AQUARIUS t January 20 - February
18n[12] t PISCES t February 19 -
March 20nn";
cout<<"Choose your Zodiac Sign in
numbers from [1-12]: ";
cin>>z;
switch(z)
{
case 1:
cout<<"nARIES t March 21 - April
19nCharacteristics: Active, Demanding,
Determined, Effective, Ambitious";
break;
case 2:
cout<<"nTAURUS t April 20 - May
20nCharacteristics: Security, Subtle
strength, Appreciation, Instruction,
Patience";
break;
case 3:
cout<<"nGEMINI t May 21 - June
20nCharacteristics: Communication,
Indecision, Inquisitive, Intelligent,
Changeable";
break;
case 4:
cout<<"nCANCER t June 21 - July
22nCharacteristics: Emotion, Diplomatic,
Intensity, Impulsive, Selective";
break;
case 5:
cout<<"nLEO t July 23 - August 22
nCharacteristics: Ruling, Warmth,
Generosity, Faithful, Initiative";
break;
case 6:
cout<<"nVIRGO t August 23 -
September 22nCharacteristics:
Analyzing, Practical, Reflective,
Observation, Thoughtful";
break;
case 7:
cout<<"nLIBRA t September 23 -
October 22nCharacteristics: Balance,
Justice, Truth, Beauty, Perfection";
break;
case 8:
cout<<"nSCORPIO t October 23 -
November 21nCharacteristics:
Transient, Self-Willed, Purposeful,
Unyielding";
break;
case 9:
cout<<"nSAGITTARIUS t November 22 -
December 21nCharacteristics:
Philosophical, Motion, Experimentation,
Optimism";
break;
case 10:
cout<<"nCAPRICON t December 22 -
January 19nCharacteristics:
Determination, Dominance, Perservering,
Practical, Willful";break;
case 11:
cout<<"nAQUARIUS t January 20 -
February 18nCharacteristics:
Knowledge, Humanitarian, Serious,
Insightful, Duplicitous";
break;
case 12:
cout<<"nPISCES t February 19 - March
20nCharacteristics: Fluctuation, Depth,
Imagination, Reactive, Indecisive";
break;
default:
cout<<"nINVALID INPUT";
}
getch( );
return 0;
}
OUTPUT:
WHILE LOOP STATEMENT
 SQUARED and CUBE 
CODES:
#include<iostream.h>
#include<conio.h>
#include<dos.h>
main( )
{
clrscr( );
int n,s,c;
cout<<" SQUARED CUBE";
n=1;
while(n<=10){
cout<<"n"<<n;
s=n*n;
cout<<"t"<<s;
c=n*n*n;
cout<<"t"<<c;
n++;
delay(1000);
}
return 0;
getch( );
}
OUTPUT:
DO-WHILE LOOP STATEMENT
 MULTIPLICATION TABLE 
CODES:
#include<iostream.h>
#include<conio.h>
main( )
{
clrscr( );
int n1,n2,n3,n4,n5,n6,n7,n8,n9,n10;
n1 = 1;
cout<<"ttttMULTIPLICATION
TABLEnn";
do{
cout<<"t"<<n1;
n1 +=1;
}
while(n1<=9);
cout<<"nn";
n2 = 2;
do{
cout<<"t"<<n2;
n2+=2;
}
while(n2<=18);
cout<<"nn";
n3=3;
do{
cout<<"t"<<n3;
n3 +=3;
}
while(n3<=27);
cout<<"nn";
n4 = 4;
do{
cout<<"t"<<n4;
n4 += 4;
}
while(n4<=36);
cout<<"nn";
n5 = 5;
do{
cout<<"t"<<n5;
n5 += 5;
}
while(n5<=45);
cout<<"nn";
n6 = 6;
do{
cout<<"t"<<n6;
n6 += 6;
}
while(n6<=54);
cout<<"nn";
n7 = 7;
do{
cout<<"t"<<n7;
n7 += 7;
}
while(n7<=63);
cout<<"nn";
n8 = 8;
do{
cout<<"t"<<n8;
n8 += 8;
}
while(n8<=72);
cout<<"nn";
n9 = 9;
do{
cout<<"t"<<n9;
n9+=9;
}
while(n9<=81);
cout<<"nn";
n10 = 10;
do{
cout<<"t"<<n10;
n10 += 10;
}
while(n10<=90);
getch( );
return 0;
}
OUTPUT:
FOR LOOP STATEMENT
 PYRAMID 
CODES:
#include<iostream.h>
#include<conio.h>
main( )
{
clrscr( );
int row, c, n, temp;
cout<<"Enter number of rows: ";
cin>>n;
temp = n;
for ( row = 1 ; row <= n ; row++ )
{
for ( c = 1 ; c < temp ; c++ )
cout<<" ";
temp--;
for ( c = 1 ; c <= 2*row - 1 ; c++ )
cout<<"*";
cout<<"n";
}
getch( );
return 0;
}
OUTPUT:

More Related Content

Recently uploaded

call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 

Recently uploaded (20)

call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

C++ Sample Codes (Data Structure)

  • 1. comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci comscicomscicomscicomscicomscicomsci PROJECT in COSC 60 Data Structure Jenelyn B. Pañoso BSCS II
  • 2. SIMPLE PROGRAMS  ARITHMETIC OPERATIONS  CODES: #include<iostream.h> #include<conio.h> main( ) { clrscr( ); int n1, n2, a, s, m; float d; cout<<“Enter two integersn”; cin>>n1; cin>>n2; a = n1 + n2; s = n1 - n2; m = n1 * n2; d = n1 / (float)n2; cout<<“nSumt = “<<a; cout<<“nDifference = “<<s; cout<<“nProductt = “<<m; cout<<“nQoutient = “<<d; getch( ); return 0; } OUTPUT:
  • 3.  VOLUME OF CYLINDER  CODES: #include<iostream.h> #include<conio.h> #define Pi 3.1416 main( ) { clrscr( ); float VOLUME,radius,height; cout<<“This program will compute the VOLUME of CYLINDER with an input of height and radius.n”; cout<<“Enter radius of CYLINDER: “; cin>>radius; cout<<“Enter height of CYLINDER: “; cin>>height; VOLUME = Pi*height*radius*radius; cout<<“nVOLUME:”<<VOLUME; getch( ); return 0; } OUTPUT:
  • 4.  MASS  CODES: #include<iostream.h> #include<conio.h> main( ) { clrscr( ); int a,b,c,gram; float d,e,f; cout<<“Enter GRAM: “; cin>>gram; a= 1000*gram; b= 100*gram; c= 10*gram; d= 0.1*gram; e= 0.01*gram; f= 0.001*gram; cout<<“Milligramt= “<<a; cout<<“nCentigramt= “<<b; cout<<“nDecigramt= “<<c; cout<<“nDecagramt= “<<d; cout<<“nHectogramt= “<<e; cout<<“nKilogramt= “<<f; getch( ); return 0; } OUTPUT:
  • 5.  VOLUME OF A CONE  CODES: #include<iostream.h> #include<conio.h> #define Pi 3.1416 main( ) { clrscr( ); float VOLUME,radius,height; cout<<“This program will compute the VOLUME of CONE with an input of height and radius.n”; cout<<“Enter radius of CONE: “; cin>>radius; cout<<“Enter height of CONE: “; cin>>height; VOLUME = Pi*height*radius+Pi*radius*radius; cout<<“nVOLUME:”<<VOLUME; getch( ); return 0; } OUTPUT:
  • 6. IF ELSE STATEMENT  NEGATIVE OR POSITIVE  CODES: #include<iostream.h> #include<conio.h> main( ) { clrscr( ); int n; cout<<"Enter a number: "; cin>>n; if(n>=0) cout<<"POSITIVE"; else cout<<"NEGATIVE"; getch( ); return 0; } OUTPUT:
  • 7. NESTED IF ELSE STATEMENT  COMPARISON  CODES: #include <iostream.h> #include <conio.h> main( ) { clrscr( ); int num1 , num2; cout<<"Enter two numbers:n"; cin>>num1>>num2; if (num1>num2) cout<<num1<<" is greater than "<<num2; else if (num1<num2) cout<<num1<<" is less than "<<num2; else if (num1==num2) cout<<num1<<" is equal to "<<num2; else cout<<"INVALID INPUT"; getch( ); return 0; } OUTPUT:
  • 8. SWITCH-CASE STATEMENT  HOROSCOPE  CODES: #include<iostream.h> #include<conio.h> main( ) { clrscr( ); int z; cout<<"[1] t ARIES t March 21 - April 19n[2] t TAURUS t April 20 - May 20n[3] t GEMINI t May 21 - June 20n[4] t CANCER t June 21 - July 22n[5] t LEO t t July 23 - August 22 n[6] t VIRGO t t August 23 - September 22n[7] t LIBRA t t September 23 - October 22n[8] t SCORPIO t October 23 - November 21n[9] t SAGITTARIUS t November 22 - December 21n[10] t CAPRICON t December 22 - January 19n[11] t AQUARIUS t January 20 - February 18n[12] t PISCES t February 19 - March 20nn"; cout<<"Choose your Zodiac Sign in numbers from [1-12]: "; cin>>z; switch(z) { case 1: cout<<"nARIES t March 21 - April 19nCharacteristics: Active, Demanding, Determined, Effective, Ambitious"; break; case 2: cout<<"nTAURUS t April 20 - May 20nCharacteristics: Security, Subtle strength, Appreciation, Instruction, Patience"; break; case 3: cout<<"nGEMINI t May 21 - June 20nCharacteristics: Communication, Indecision, Inquisitive, Intelligent, Changeable"; break; case 4: cout<<"nCANCER t June 21 - July 22nCharacteristics: Emotion, Diplomatic, Intensity, Impulsive, Selective"; break; case 5: cout<<"nLEO t July 23 - August 22 nCharacteristics: Ruling, Warmth, Generosity, Faithful, Initiative"; break; case 6: cout<<"nVIRGO t August 23 - September 22nCharacteristics: Analyzing, Practical, Reflective, Observation, Thoughtful"; break; case 7:
  • 9. cout<<"nLIBRA t September 23 - October 22nCharacteristics: Balance, Justice, Truth, Beauty, Perfection"; break; case 8: cout<<"nSCORPIO t October 23 - November 21nCharacteristics: Transient, Self-Willed, Purposeful, Unyielding"; break; case 9: cout<<"nSAGITTARIUS t November 22 - December 21nCharacteristics: Philosophical, Motion, Experimentation, Optimism"; break; case 10: cout<<"nCAPRICON t December 22 - January 19nCharacteristics: Determination, Dominance, Perservering, Practical, Willful";break; case 11: cout<<"nAQUARIUS t January 20 - February 18nCharacteristics: Knowledge, Humanitarian, Serious, Insightful, Duplicitous"; break; case 12: cout<<"nPISCES t February 19 - March 20nCharacteristics: Fluctuation, Depth, Imagination, Reactive, Indecisive"; break; default: cout<<"nINVALID INPUT"; } getch( ); return 0; } OUTPUT:
  • 10. WHILE LOOP STATEMENT  SQUARED and CUBE  CODES: #include<iostream.h> #include<conio.h> #include<dos.h> main( ) { clrscr( ); int n,s,c; cout<<" SQUARED CUBE"; n=1; while(n<=10){ cout<<"n"<<n; s=n*n; cout<<"t"<<s; c=n*n*n; cout<<"t"<<c; n++; delay(1000); } return 0; getch( ); } OUTPUT:
  • 11. DO-WHILE LOOP STATEMENT  MULTIPLICATION TABLE  CODES: #include<iostream.h> #include<conio.h> main( ) { clrscr( ); int n1,n2,n3,n4,n5,n6,n7,n8,n9,n10; n1 = 1; cout<<"ttttMULTIPLICATION TABLEnn"; do{ cout<<"t"<<n1; n1 +=1; } while(n1<=9); cout<<"nn"; n2 = 2; do{ cout<<"t"<<n2; n2+=2; } while(n2<=18); cout<<"nn"; n3=3; do{ cout<<"t"<<n3; n3 +=3; } while(n3<=27); cout<<"nn"; n4 = 4; do{ cout<<"t"<<n4; n4 += 4; } while(n4<=36); cout<<"nn"; n5 = 5; do{ cout<<"t"<<n5; n5 += 5; } while(n5<=45); cout<<"nn"; n6 = 6; do{ cout<<"t"<<n6; n6 += 6; } while(n6<=54); cout<<"nn"; n7 = 7; do{ cout<<"t"<<n7; n7 += 7; } while(n7<=63); cout<<"nn"; n8 = 8; do{ cout<<"t"<<n8; n8 += 8; } while(n8<=72);
  • 12. cout<<"nn"; n9 = 9; do{ cout<<"t"<<n9; n9+=9; } while(n9<=81); cout<<"nn"; n10 = 10; do{ cout<<"t"<<n10; n10 += 10; } while(n10<=90); getch( ); return 0; } OUTPUT:
  • 13. FOR LOOP STATEMENT  PYRAMID  CODES: #include<iostream.h> #include<conio.h> main( ) { clrscr( ); int row, c, n, temp; cout<<"Enter number of rows: "; cin>>n; temp = n; for ( row = 1 ; row <= n ; row++ ) { for ( c = 1 ; c < temp ; c++ ) cout<<" "; temp--; for ( c = 1 ; c <= 2*row - 1 ; c++ ) cout<<"*"; cout<<"n"; } getch( ); return 0; } OUTPUT: