Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: Computer science All programmes
Description: it contains all programmes for class 11 from beginning to end

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


COMPUTER SCIENCE
All Programmes

THIS PDF CONTAINS ALL PROGRAMMS OF C++ ( CLASS 11 )

1
...

#include ...


2
...

#include ...
Program to find square of a number
...
h>
void main()
{
int num1,square;
cout<<"Enter number: ";
cin>>num1;
square=num1*num1;
cout<<"Square of number is: "<}

OUTPUT
Enter number:

5

Square of number is: 25

4
...

#include ...
h>
void main()
{
clrscr();
int num1,num2;
cout<<"Enter value for num 1: ”;
cin>>num1;
cout<<"Enter value for num 2: ";
cin>>num2;
if(num1>num2)
cout<<"Num1 is greater than num 2";
else
cout<<"Num1 is smaller than num 2";
}

OUTPUT
Enter value for num 1: 5
Enter value for num 2: 10
Num1 is smaller than num 2

5
...

#include ...
33333333

6
...

#include ...
Program that reads radius of a circle and prints its area
...
h>
void main()
{
float radius,area;
cout<<"Enter Radius of circle:

";

cin>>radius;
area=radius*3
...
44

8
...

#include ...
h>
void main()
{
clrscr();
int x,y,z;
cout<<"Enter x: ";
cin>>x;
y=2*x;
z=2*x-1;
cout<<" Y = "<cin>>totaldays;
years=totaldays/365;
rem1=totaldays%365;
weeks=rem1/7;
rem2=rem1%7;
days=rem2;
cout<<"Years = "<cin>>a;
cout<<"Enter b : ";
cin>>b;
c=a;
a=b;
b=c;
cout<<"\na= "<}

OUTPUT
Enter a: 5
Enter b: 7
a= 7
b= 5

11
...

#include ...
h>
void main()
{
clrscr();
int a,b;
cout<<"Enter a : ";
cin>>a;
cout<<"Enter b : ";
cin>>b;
a=a+b;
b=a-b;
a=a-b;
cout<<"Values after swapping: "<<"\na= "<}

OUTPUT
Enter a: 4
Enter b: 9
Values after swapping:
a= 9
b= 4

12
...

#include ...
Program to check whether the entered number is odd
or even
...
h>
#include ...
Program to find Simple Interest and Compound
Interest
...
h>
#include ...
Program to find area of a triangle
...
h>
#include ...
Program that seeds the name of user and number
of unit and displays the electricity charge with name
...


#include ...
h>
#include ...
Program to enter marks in five subjects and
calculate percentage
...

Percentage

Grade

>90

A

<= 90 and>81

B

<= 80 and>71

C

<= 70 and>61

D

<= 60 and>51

E

<= 50 and>41

F

<=40

Fail

#include ...
h>
#include ...
Program that accepts a character between A and J and
prints next 4 characters
...
h>
#include ...
Program to input a student type (‘A’ or ‘B’), and for
‘A’ initialize the collage account with Rs 200 otherwise
initialize the hostel account with Rs 200
...
h>
void main()
{
char stu_type;
int coll_acc,hostel_acc;
cout<<"Enter student type: ";
cin>>stu_type;
if(stu_type=='A')
coll_acc=200;
cout<<“\nCollage account:”<if(stu_type=='B')
hostel_acc=200;
cout<<“\nHostel account:”<}

OUTPUT
Enter student type: A
Collage account: 200

20
...
h>
void main()
{
char choice;
int radius, area, peri;
cout<<"Enter radius of circle: ";
cin>>radius;
cout<<"Enter 1 for area or 2 for perimeter: ";
cin>>choice;
area=22*radius*radius/7;
peri=2*22*radius/7;
if(choice=='1')
cout<<"Area: "<else
cout<<"Perimeter: "<}

OUTPUT
Enter radius of circle: 7
Enter 1 for area or 2 for perimeter: 1
Area: 154

21
...
The
value of w, x, y, z are entered by user
...
h>
void main()
{
float w, x, y, z, P;
cout<<"Enter numbers w, x, y, z";
cin>>w>>x>>y>>z;
P= (w + x)/(y-z);
cout<<"\nP = (w + x)/(y-z) =
}

OUTPUT
Enter numbers w, x, y, z
5
7
6
3

P = (w + x)/(y-z) = 4

"<
22
...

#include ...
h>
#include ...
Program to calculate commission for the salesmen the
commission is calculated according to following rates
...
h>
#include ...
15;

else
cout<<"Commission = "< ...
07;
else
cout<<"Commission = "< ...
2

24
...
The ASCII codes are given below
...
h>
#include ...
Program to print table of any number
...
h>
#include ...
Program to print roots of a quadratic equation
...
h>
#include ...
h>
void main()
{
clrscr();
float a,b,c,root1,root2,delta;
cout<<"Enter the values of a, b & c of the quadratic equation of the form
\nax2+bx+c \n";
cin>>a>>b>>c;
if(a==0)
cout<<"The value of 'a' should not be zero \n Abording!!!!! \n";
else
{
delta =b*b-4*a*c;
if(delta>0)
{
root1=(-b+sqrt(delta))/(2*a);
root2=(-b-sqrt(delta))/(2*a);
cout<<"Roots are real and unequal";
cout<<"\n root1= "<cout<<"\n root2= "<}

else if(delta==0)
{
root1=root2=-b/(2*a);
cout<<"Roots are real and equal";
cout<<"\n Root1= "<cout<<"\n Root2= "<}
else
cout<<"roots are complex \n";
}
}

OUTPUT
Enter the values of a, b & c of the quadratic equation of the form
ax2+bx+c
1
-5
4
Roots are real and unequal
Root1= 1
Root2= 4

27
...


#include ...
h>
#include ...
Program that prints the following series
1

2

4

8

16

32 64 128

#include ...
h>
#include ...
Program that prints first n natural numbers and prints
their sum
...
h>
#include ...
Program to print sum of even and odd natural
numbers in first n natural numbers
...
h>
void main()
{
int n,i,sum1=0,sum2=0;
cout<<"Enter the number of numbers : ";
cin>>n;
for(i=1;i<=n;i++)
{if(i%2==0)
sum1+=i;
else
sum2+=i;
}
cout<<"\nSum of even numbers: "<cout<<"\nSum of odd numbers: "<}

OUTPUT
Enter the number of numbers: 10
Sum of even numbers: 30
Sum of odd numbers: 25

31
...


#include ...
h>
void main()
{
clrscr();
int i,j;
for(i=1;i<=5;i++)
{
cout<<"\n";
for(j=1;j<=i;j++)
cout<<'*';
}
}

OUTPUT
*
**
***
****
*****

32
...


#include ...
h>
void main()
{
clrscr();
int i,j;
for(i=1;i<=4;i++)
{
cout<<"\n";
for(j=1;j<=2*i-1;j++)
cout<<'*';
}
}

OUTPUT
*
***
*****
*******

33
...


#include ...
h>
void main()
{
clrscr();
int i;
for(i=1;i<=5;++i)
{
cout<<"\n";
for(int j=1;j<=i;++j)
cout<}
}

OUTPUT
1
22
333
4444
55555

34
...


#include ...
Program to print factorial of a number
...
h>
#include ...
Program for generating the given output
...
h>
void main()
{
char ch;
int i=ch, j, n;
cout<<"Enter number of lines: ";
cin>>n;
for(i=65;i<=n+65;i++)
{
cout<<"\n";
for(j=65;j<=i;j++)
cout<}
}

OUTPUT
Enter number of lines: 4
A
AB
ABC
ABCD

37
...

#include ...
Program to check whether a number is palindrome or
not
...
h>

#include ...
Program to check whether entered character is an
alphabet or not
...
h>
#include ...
";
else
cout<<"It is not an alphabet
...


Enter character: %
It is not an alphabet
...
Program to check whether the entered character is
of uppercase or lowercase
...
h>

#include ...
\n";
if(isupper(ch))
cout<<"It is an upper case
...
";

}
else
cout<<"It is not an alphabet
...

It is a lower case
...
Program to concatenate two strings
...
h>
#include ...
h>
void main()
{
char s1[10], s2[10];
cout<<"Enter string 1:";
gets(s1);
cout<<"Enter string 2:";
gets(s2);
cout<
}

OUTPUT
Enter string 1: GOOD
Enter string 2: LUCK
GOODLUCK
Enter string 1: WEL
Enter string 2: COME
WELCOME

42
...

#include ...
h>

void main()
{
int n=1;
char str[100];
cout<<"Enter line:";
cin
...

Number of words = 5
Enter line: Program to find out number of words present in a line
...
Program to print a word by deleting 1 letter from
end in each turn
...
h>
#include ...
getline(str,25);
int len=strlen(str);
for(int i=len; i<=0; i--)
{

for(int j=0; j<=i; j++)
cout<cout<<“\n”;

}
}

OUTPUT
Enter string: HELLO
HELLO
HELL
HEL
HE
H

44
...

#include ...
h>
void main()
{

char str[20];

int len, i, f=1;
cout<<"Enter string:";
cin
...
";
else
cout<<"Entered string is not a palindrome
...


45
...

#include ...
h>
#include ...
getline(str,20);
cout<<"Enter character:";
cin>>ch;
for(i=1; i<=len; i++)
{
if(str[i]==ch)
{
f=1;
break;
}
}
if(f==1)
cout<<“The given character is present in the
string
...
”;

}

OUTPUT
Enter string: My name is Khan and I am not a terrorist
...
Program to find cube of a number (using
function)
...
h>
int cube(int);
void main()
{
int a,c;
cout<<"Enter number: ";

cin>>a;
c=cube(a);
cout<<"Cube of the number: "<}
int cube(int b)
{
int n;
n=b*b*b;
return n;
}

OUTPUT
Enter number: 5
Cube of the number: 125

47
...
The list
terminates as soon as one enters zero (using function)
...
h>
#include ...
Program to calculate factorial of a number (using
function)
...
h>
void factorial(int);
void main()
{

int n;
cout<<"Enter number:";
cin>>n;
factorial(n);

}

void factorial(int n)
{

int fact=1;
int i;
for(i=1; i<=n; i++)
fact=fact*i;
cout<< “\nFactorial of ”<
}

OUTPUT
Enter number: 6
Factorial of 6 is 720

Enter number: 5
Factorial of 6 is 120

49
...

entered through keyboard (using function)
...
h>
void largest();
void main()
{

largest();

}
void largest()
{

char ans='y'; int n, large=0;
while(ans=='y')

{

cout<<"Enter number:";
cin>>n;
if(n>large)
large=n;
cout<<"You want to enter number?(y or n):";
cin>>ans;

}
cout<< “\n Largest number entered: ”<}

OUTPUT
Enter number: 5 6 8 45 68 26 65 35 79 65 -6 64 25 64 3 9 10
Largest number entered: 79

50
...

#include ...
Program to find largest and smallest element in a
vector
...
h>
void main()
{

int v[10], large, small, i;
cout<<"Enter the value in vector ";
for(i=0;i<10; i++)
cin>>v[i];
large=v[1];
small=v[1] ;
for (i=0;i<10;i++)

{

if(v[i]>large)
large=v[i];
else if(v[i]small=v[i];

}
cout<<"\n Largest element ="<cout<<"\n Smallest element= "<}

OUTPUT
Enter the value in vector
5

6

8

4

3

4

9

5

1

2

Largest element = 9
Smallest element= 1

52
...

#include ...

cout<< “\nNum1”<
}

OUTPUT
Enter num1: 9
Enter num2: 15
Value after swapping numbers
...
Program to find sum of digits of a number (using
function)
...
h>
int sum(int);
void main()
{

int n,s;
cout<<"Enter number:";
cin>>n;
s=sum(n);
cout<< “\n Sum of digits :”<
}
int sum(int n1)
{

int p=0;
while(n1)
{

p=p+(n1%10);
n1=n1/10;

}
return p;
}

OUTPUT
Enter number:356
Sum of digits : 14

54
...

#include ...
Program to print and convert all the elements of
an array positive (using function)
...
h>
void negative(int arr[],int);
void main()
{

int size=10, arr[size];
cout<<"Enter elements of an array:";
for(int i=0; icin>>arr[i];
negative(arr,size);

}

void negative(int arr1[], int size1)
{

for(int i=0; i{

if(arr1[i]<0)
arr1[i]=arr1[i]*-1;

}
for(i=0;icout<}

OUTPUT
Enter elements of an array:
1

2

-6

-8

5

-9

5

4

8

-9

1

2

6

8

5

9

5

4

8

9

56
...

#include ...
Program to display a 2D array in 1D array
...
h>
void main()
{

int A[3][3], B[9];
int i,j,k=0;
cout<<"Enter Array A:";
for(i=0; i<3; i++)
for(j=0; j<3; j++)
cin>>A[i][j];
for(i=0; i<3; i++)
{

cout<<"\n";

for(j=0; j<4; j++)
cout<for(i=0; i<3; i++)
for(j=0; j<3; j++)
{

B[k]=A[i][j];
k++;}

for(k=0; k<9; k++)
cout<}

OUTPUT
Enter Array A:

123
123
123

Array B:

123123123

58
...

#include ...
Program to replace a number from array with 0
and take all 0s of the array to the left
...
h>
void main()
{
int arr[9], n, t, k;
cout<<"Enter array:";
for(int i=0; i<9; i++)
cin>>arr[i];

cout<<"Enter number:";
cin>>n;
for(i=0; i<9; i++)
{
if(arr[i]==n)
arr[i]=0;
}
for(i=0; i<9; i++)
cout<cout<<"\n";
for(k=0;k<2; k++)
{
for(i=8; i>=0; i--)
{
if(arr[i]==0)
{
for(int j=i;j>0;j--)
{
t=arr[j];
arr[j]=arr[j-1];
arr[j-1]=t;
}
}

}
}
cout<< “Array after replacing ”<for(i=0; i<9; i++)
cout<}

OUTPUT
Enter array:

6

5

4

6

9

5

1

5

8

0

6

4

6

9

1

8

Enter number: 5
Array after replacing ‘5’:
0

0

60
...

#include ...
Program to multiply two matrices
...
h>
#include ...
Program to delete duplicate elements of an array
with 0 and take all 0 to right
...
h>
void main()
{

int A[10];
cout<<"Enter array:";
for(int i=0; i<10; i++)
cin>>A[i];
for(i=0; A[i]!='\0'; i++)

{

for(int j=i+1; A[j]!='\0'; j++)
{

if(A[i]==A[j])
{

for(int k=j; A[k]!='\0'; k++)
A[k]=A[k+1];

}

}}
for(i=0; A[i]!='\0'; i++)
{

if(A[i]==0)
A[i]='\0';

}

cout<< “\nNew array:”;
for(i=0; i<10; i++)
cout<}

OUTPUT
Enter array: 5

8

9

6

4

8

9

3

6

5

New array: 5

8

9

6

4

3

0

0

0

0

63
...

Details (including costume name, code and date of starting,
number of years, interest rate and total amount) are stored
in an array of structures
...
h>
#include ...
h>
#include ...
cname);
cin>>c[i]
...
cday;
cin>>c[i]
...
cyear;
cin>>c[i]
...
irate;
cin>>c[i]
...
irate*0,01);
s[i]=pow(t[i],c1[i]
...
totalamount*s[i];
cout<}

}

64
...

#include ...
h>
#include ...
h>
struct employee
{

int eno;
char ename[20];
char eaddress[20];
}e[10];
void main()
{
clrscr();
int i,n;
char ans='y';
for(i=0;i<10;i++)
{
cin>>e[i]
...
ename);
gets(e[i]
...
eno)
{
cout< ...
ename);
puts(e[i]
...
Program to create an array containing details of
25 students (including Roll number, name, marks in
three subjects) and print out a list of students who
have failed in more than 1 subject
...

#include ...
h>
#include ...
rno;
cout<<"Enter student name : ";
gets(s[i]
...
sub1>>s[i]
...
sub3;
}
cout<<"list of students failed in more than 1 subject";
int f=0;
for(i=0;i<25;i++)
{
if(s[i]
...
sub2<=40)
f++;

if(s[i]
...
name)
cout<
Title: Computer science All programmes
Description: it contains all programmes for class 11 from beginning to end