Академический Документы
Профессиональный Документы
Культура Документы
BSCS-11M1
PROGRAM:
#include<iostream.h>
for(a=0;a<10;a++){
#include<conio.h>
for(b=0;b<10;b++){
int value[10];
int x;
int y;
int a;
int b;
main(){
clrscr();
if(value[a]<value[b]){
y=value[a];
value[a]=value[b];
value[b]=y;
}}}
cout<<endl;
cout<<"Values arranged in ascending
order:\n";
cout<<"****************************
for(x=0;x<10;x++){
************************\n";
cout<<value[x]<<" ";
cout<<endl;
cout<<"\nPress any key to
continue...";
getch();
}
OUTPUT:
cout<<"Input 10 values:\n";
#include<conio.h>
for(x=0;x<10;x++)
int value[10];
cin>>value[x];
int x;
for(a=0;a<10;a++){
int y;
for(b=0;b<10;b++){
int a;
int b;
if(value[a]>value[b]){
y=value[a];
main(){
value[a]=value[b];
clrscr();
value[b]=y;
cout<<"****************************
}}}
*************************\n";
cout<<"THIS PROGRAM WILL SORT THE
VALUES IN DESCENDING ORDER\n";
cout<<"****************************
*************************\n";
cout<<endl;
cout<<endl;
cout<<"Values arranged in
descending order:\n";
for(x=0;x<10;x++){
cout<<value[x]<<" ";
continue...";
getch();
cout<<endl;
OUTPUT:
3. Create a program that will determine the even and odd numbers from the input
values.
PROGRAM:
#include<iostream.h>
cout<<"****************************
#include<conio.h>
***********************************
int a[10];
int x;
main(){
clrscr();
**********"<<endl;
cout<<"THIS PROGRAM WILL IDENTIFY
THE EVEN AND ODD NUMBERS FROM THE
VALUES GIVEN"<<endl;
cout<<"****************************
***********************************
**********\n"<<endl;
cout<<"Input 10 values:\n";
if(a[x]%2!=0){
for(x=0;x<10;x++)
cout<<a[x]<<" ";
cin>>a[x];
cout<<"\nEven values:\n";
cout<<endl;
for(x=0;x<10;x++)
if(a[x]%2==0){
continue...";
cout<<a[x]<<" ";
}
cout<<endl<<endl;
cout<<"Odd values:\n";
for(x=0;x<10;x++)
OUTPUT:
getch();
}
4. Create a program that will determine the prime numbers from the input values
PROGRAM:
#include<iostream.h>
#include<conio.h>
for(x=0;x<10;x++){
int a[10];
int b;
int x;
int y;
main(){
clrscr();
if(a[x]%2==0&&a[x]!=2){
cout<<a[x]<<" ";
}}
cout<<endl;
cout<<"\nValues divisible by 3:\n";
for(x=0;x<10;x++){
if(a[x]%3==0&&a[x]!=3){
cout<<"****************************
cout<<a[x]<<" ";
**********************************\
}}
n";
cout<<"THIS PROGRAM WILL IDENTIFY
PRIME NUMBERS FROM THE INPUT
VALUES\n";
cout<<endl;
cout<<"\nThe Prime Numbers are:\n";
for(x=0;x<10;x++){
cout<<"****************************
if((a[x]%2!=0&&a[x]%3!=0)||(a[x]==2
**********************************\
|a[x]==3))
n";
cout<<a[x]<<" ";
}
cout<<endl;
cout<<endl;
cout<<"Input 10 values:\n";
continue...";
for(x=0;x<10;x++)
cin>>a[x];
getch();
}
OUTPUT: