cs1 Output
cs1 Output
Aim: Write a program in C++ that first initializes an array of given 10 real numbers. The
program must sort numbers in ascending order using Bubble Sort method. It should print
the given list of numbers as well as the sorted list
#include<iostream.h>
int main() {
// Declare variables
cin >> n;
temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
return 0;
}Output
Expt. No. 3: Searching a number in an array using Binary Search technique.
Aim:Write a program in C++ that first initializes an array of given 10 sorted real numbers.
The program must verify whether a given element belongs to this array or not, using
Binary Search technique. The element (to be searched) is to be entered at the time of
execution. If the number is found, the program should print its position in the array
otherwise it should print, “The number is not found”.
#include <iostream.h>
#include <conio.h>
void main()
{
int n,i,beg,end,mid,flag;
n=10;flag=0;
double a[10],x;
clrscr();
cout<<"Enter sorted array:";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"\nEnter the no. that is to be searched:";
cin>>x;
beg=0;
end=n-1;
while(beg<=end)
{
mid=(beg+end)/2;
if(x==a[mid])
{
flag=1;
break;
}
if(x<a[mid])
end=mid-1;
else
beg=mid+1;
}
if(flag==1)
cout<<"\nThe no. is found at location: "<<mid+1;
else
cout<<"\nThe no. is not found";
getch();
}
1
#include<string.h>
// Main function
int main() {
int len;
char str[100];
cin.getline(str, 100);
len = strlen(str);
swap(len, str);
char temp;
int l = length - 1;
// Swap characters from the beginning and end of the string towards the center
temp = s[i];
s[i] = s[l];
s[l] = temp;
l--;
Output
Expt. No. 10: Implementing inheritance.
Aim: Write a program in C++ to implement the following class hierarchy. Class Student to
obtain Roll no., Class Test to obtain marks in two different subjects, Class Sports to obtain
weightage in sports, and class Result to calculate total marks. The program must print the
roll no., individual marks obtained in two subjects, sports and total marks.
#include<iostream.h>
#include<conio.h>
class student {
private:
int rollno;
public:
void setno(int a) {
rollno = a;
void putno() {
};
protected:
public:
sub1 = x;
sub2 = y;
void putmarks() {
};
class sports {
protected:
float score;
public:
void setscore(float s) {
score = s;
void putscore() {
};
private:
float total;
public:
void display() {
putno();
putmarks();
putscore();
};
void main() {
int rn;
result r;
clrscr(); // Clear the screen
r.setno(rn);
r.setmarks(s1, s2);
r.setscore(sc);
r.display();
Output
Expt. No. 15: Working with tables and images in HTML.
Aim: Create a simple HTML page on any of the following topics: College Profile, Computer
Manufacturer, or Software Development CompanyThe page must consist of a scrolling
marquee displaying an appropriate message. The page must include table with at least five
rows and 3 columns having merged cells at least at one place. The page must also display
an Image such that when the same is viewed through a browser and the mouse is placed
(hovered) on the image, an appropriate text message should be displayed. The image itself
should also act as a hyperlink to another page
<!DOCTYPE html>
<html>
<head>
<title>FRIENDS.jr.collage of science</title>
</head>
<body bgcolor="pink">
<center>
<a href="features1.html">
</a>
</center>
<marquee><h3>Updated on 1.10.2012</h3></marquee>
<tr>
<th>Department</th>
<th colspan="2">Staff</th>
</tr>
<tr>
<td>Physics</td>
</tr>
<tr>
<td>Biology</td>
</tr>
<tr>
<td>Chemistry</td>
<td colspan="2">Regina</td>
</tr>
<tr>
</tr>
</table>
</body>
</html>