Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 40

ACKNOWLEDEMENT

An ostentatious use of words will not suffice in acknowledging the


deep sense of grattitude,which we owe to our teacher and supervisor Miss
Nooreen Zaidi ,for her credit supervision of this work,through her
encyclopedic knowledge in the field of Computer . For this sake ,she
devoted her valuable time for discussing the problems in detail . Her
encouraging attitude ., considerate nature and simplicity are beyond our
vocabulary to express.
I record my deep sense of appreciation to the authorities of the
libraries for providing me necessary details and facilities through which
we made a project .
In the last,we are thankful to all my friends .my family members
and collegue who created a happy atmosphere and supported me at each and
every moment.

Ta n i s h a s o l a n k i

&
Pragya singh
Program to find the hottest and coolest
days of a month

#include <iostream.h>
Main()
{
int temp[31],days;
int I, max,min,avg;
cout << “how many days in the month?”;
cin >> days;
for (i = 0; I < days; i++)
{
cout << “enter noonday temperture for day” << i+1<<“:”;
cin>> temp[i]:
}
// find average temperature
avg = 0;
for (i = 0; i < days; i++)
avg = avg + temp[i];
cout << “Average temperature : “ << avg/days << “\n”;
// find the minimum and maximum temperature in the month
min = 100;
max = 0;
for (i =0 ; I <days; i ++)
{
if (min>temp[i])
min=temp[i];
if (max<temp[i])
max=temp[i];
}
cout<<“maximum temperature:”<<max<<endl;
cout<<“minimum temperature:”<<min<<endl;
return 0;
}
//Program to calculate the total salary of n
employee(s) and find who gets highest
salary.
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
int empno[50];
int da[50],hra[50],total[50],i,n,max,no;
char a[50][20];
cout<<“\n\t Enter the data of employee”;
cin>>n;
Cout<<“\n\t enter the data of employee”;
for(i=0;i<n;i++)
{
cout<<“\n\t enter name”;
cin>>a[i];
cout<<“\n\t enter number”;
cin>>empon[i];
cout<<“\n\t enter basic salary”;
cin>>basic[i]
da[i]=basic[i]*20/100;
hra[i]=basic[i]*30/100;
total[i]=basic[i]+da[i]+hra[i];
}
max=total[0];
for(i=1;i<n;i++)
{
if(max<total[i])
{
max=total[i];
no=empo[i];
}
clrscr();
cout<<“NAME EMP NO. BASIC TOTAL\n”;
cout<<“---------------------------\n”;
for(i=0;i<n;i++)
{
cout<<setw(2)<<a[i]<<setw(17)<<empo[i]<<setw(17)<<basic[i]
<<setw(17)<<total[i]<<endl;
}
cout<<“\n\t Highest salary:”<<max;
cout<<“\n\t Employee number is:”<<no;
}
//Program to print the city name of
corresponding country
#include<iostream .h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
Main()
{
clrscr();
char cout[10][15],x[10];
int l,i=0,cout=0;
cout<<“Please note to stop enter xxx\n”;
do
{
cout<<“Enter name of the country=>”;
gets(cap[i]);
i++;
cout++;
}while(1);
cout<<“Enter the name of the country whose city is required”;
gets(x);
i=0;
while(i<cout)
{
if(strcmp(coun[i],x)==0
{
l=i ;
break;
}
i++;
}
if(l<0)
cout<<“the country does not exit “;
else
cout<<“The city for the given country is”<<cap[i];
}
//Program to store quantity and cost in
a two dimensional matrix.
#include <iostream.h>
#<include<conio.h>
#include<iomanip.h>
Main()
{
int shop[10][2];
clscr();
for(int i=0;i++)
{
cout<<“Enter the product Cost and Quantity”;
for(int j=0;j<2;j++
{
cin>>shop[i][j];
}
}
clrscr();
cout<<“Cost/Unit(Rs.) Quantity\n”;
for(i=0;i<10;i++)
{
cout<<setw(4)<<shop[i][0]<<setw(23)<<shop{i}{1}<<endl;
}
}
//Program to find the sum of a 3X4
matrix
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
Main()
{
clrscr();
int a[3][4],b3][4],i,j;
cout<<“\n\tEnter First Matrix”;
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
cin>>a[i][j];
}
}
cout<<“\n\tEnter Second Marix”;
for(i=0;i<3;i++)
{
for(j=0<4;j++)
{
cout<<“\t\t”<<sum[i][j];
}
}
cout<<“\n\t The Resultant array is\n”;
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
cout<<“\t\t”<<sum[i][j]<<“ “;
}
cout <<“\n”;
}
getch();
return 0;
}
calendar month.
#include<iostream.h>
#include<conio.h>
Main()
{
clrscr();
int data[6][7]’i’j;
cout<<“Enter the data\n”;
int x=1;
if(choice==3)
{
cout<<“\nEnter the capita to be searched”;
cin>>tpcincome;
for(i=0;i<10;i++)
{
if(x[i].pcincome==tpcincome)
{
cout<<“\nName:”<<x[i].name;
cout<<“\nCapital:”<<x[i].capital;
cout<<“\nPer capita income:”<<x[i].pcincome;break;
}
}
}
}
Program to store CDs to track the
storage and movement in casette library.
#include<iostream.h>
#include<string.h>
#include<conio.h>
Struct CDLibrary
{
char Cdtitle[20];
float CDDuration;
float Cdcost;
float Cdrent;
char CDDate[10];
}; // Structure for CD Library
CDLibrary CD[10]; // Structure variable declared
Char ans;
void main()
{
clrscr();
int i=0;
do
{
clrscr();
cout<<“Enter CD Title= >”;
cin>> CD[i].Cdtitle;
cout<<“Enter CD duration = >”;
cin>> CD[i].CDDuration;
cout<<“Enter CD Cost = >”;
cin>>CD[i].CDcost;
cout<<“Enter CD Rent cost = >”;
cin>> CD[i].Cdrent;
cout<<“Enter CD Release date = >”;
cin>>CD[I].CDDate;
cout<<“DO You Want To Continue…..”;
cin>>ans;
i++;
}
while(ans = =‘y’);
}
Program to find out total salary of
an employee.
#include<stdio.h>
#include<conio.h>
Void main()
{
int total;
struct emp
{
int basic_sal;
float total_allowance;
};
sruct emp e;
clrscr();
printf(“Enter the basic salary and allowance \n”);
scanf(“%d”,&e.basic_sal);
scanf(%d”,&e.total_allowance);
total=e.basic_sal+e.total_aloowance;
printf(“Total salary=%d”,total);
getch();
}
Output
Enter the basic salary and allowance
8000
4500.20
Total =12500.20
Program to print the sum of digits
of 3 digit number
#include <conio.h>
#include <stdio.h>
Void main()
{
int num;
int I,sum=0;
clrscr();
printf(“Enter any 3 digit number \n”);
scanf(“%d”,&num);
i=num % 10;
num = num \10;
sum = sum+i ;
i=num%10;
num=num \10
sum=sum + i ;
i=num;
sum=sum +I ;
printf (“sum =%d”,sum);
getch();
}
OUTPUT
Enter any 3 digit number
251
Sum =8
Write a program to check
whether the input year is leap
year or not.
#include<stdio.h>
#include <conio.h>
Void main()
{
int yr ;
clrscr();
printf (“Enter the year \n”);
scanf (“%d”,&yr);
if(yr%4= =0)
printf (“leap year”);
else
printf(“Not a leap year”);
getch();
}
OUTPUT
Enter the year
2011
Not a leap year
and translate to its equivalent name of the day of
the week.
#include <iostream.h>
int main()
{ int dow ;
cout <<“Enter number of week’s day (1-7):”;
cin >>dow ;
switch (dow)
{
case 1: cout<<“\n”<<“January” ;
break;
case 2: cout<<“\n”<<“February” ;
break ;
case 3: cout<<:\n”<<“March” ;
break ;
case 4: cout<<“\n”<<“April” ;
break ;
case 5: cout<< “\n”<<“May” ;
break ;
case 6: cout<<“\n”<<June” ;
break ;
case 7: cout<<“\n”<<July” ;
break ;
case 8: cout<<“\n”<<August” ;
break ;
case 9: cout<<“\n”<<September” ;
break ;
case 10: cout<<“\n”<<October” ;
break ;
case 11: cout<<“\n”<<November” ;
break ;
case 12: cout<<“\n”<<December” ;
break ;
default : cout<<“\n”<<“Wrong number of day” ;
break ;
}
return 0 ;
}
Output
Enter number of month’s day(1-12): 8
August
Write a program to print the division
secured by the student .
# include <conio.h>
# include <stdio.h>
void main()
{
int marks;
clrscr();
printf (“Enter the percentage of marks of students “)]
scanf (“%d”,& marks);
if (marks> =75)
{
printf(“Distinction”);
printf(“\n”);
}
else if {marks>=60&& mark<75)
{
print(“first Division”);
print(“\n”) ;
}
else if (marks>=45 && mark<60)
{
printf(“second division”) ;
printf(“\n”) ;
}
else if (marks>=30 && mark<45)
{
printf (“Third division”) ;
printf(“\n”) ;
}
else
{
printf(“FAIL”) ;
}
getch() :
}
WAP to create a structure library to
store books in school.
#include<iostream.h>
#include<string.h>
#include<stdio.h>
#include<conio.h>
Struct library
{
char acc_no[10] ;
char title[35]
char author[25] ;
float Bcost ;
char iss Date [10] ;
};
Library lib[100] ;
char ani ;
void main()
{ clrscr() ;
int i=0 ;
do
{ clrscr() ;
cout<<“Enter accesion no. =>”;
cin>>lib [i].acc_no. ;
cout <<“Enter tittle = >” ;
gets (lib[i].title) ;
cout <<“Enter author name =>” ;
gets (lib [i].author) ;
cout <<“Enter book cost =>” ;
cin>> lib[i].Bcost ;
cout<<“Enter issue date=>” ;
cin>>lib [i].iss Date ;
cout <<“Do You Want 2 Continue……….” ;
cin>>ans ;
i++ ;
}
while (ans ==‘y’) ;
Program to find total salary
of employee.
#include<iostream.h>
#include<conio.h>
Void main( )
{
int mat[3] [3] ;
int max 2, max =0 ;
clrscr ( ) ;
cout <<“Enter the Array \n” ;
for {int i=0;i<3; i++)
{
for(int j=0; j<3; j++)
{
cin>>mat[i] [j] ;
}
}
for (i=0 ;i<3 ;i++ )
{
for (int j=0;j<3 ;j++)
{
if (mat [i][j]>max)
{
max =max ;
max=mat[i] [j] ;
}
}
}
cout<<“The second Maximum Element of the
Matrix “<<max 2 ;
getch( ) ;
}
Multiply and Divide two
complex numbers.
#include <iostream.h>
#include <conio.h>
struct compex
{
int real ;
};
complex num 1, num 2 ;
void main ( )
{ clrscr ( ) ;
void multiply(complex num1,complex num 2) ;
void division(complex num 1,complex num 2) ;
cout<<“\n Enter the real part of first complex number->” ;
cin>>num1.real ;
cout <<“\n Enter the imaginary part of ffirst number->” ;
cin>>num 1.imag ;
cout <<“\n Enter the real part of second complex no.->” ;
cin .num 2 . Real ;
cout <<“\n Enter the imaginary part of second number->” ;
cin>>num 2.img ;
multiply (num 1,num 2) ;
divisor (num1,num 2);
}
void multiply (complex num 1.complex num 2)
{
complex prod ;
prod .real =num 1.real *num 2.real ;
prod .image =num 1 .imag *num2 .imag ;
cout <<“\n Product of 2 real no’s is =“<<prod .real <<“+i”<<prod .imag;
}
void division(complex num 1,complex num 2)
{ conplex div ;
div real = num 1.real /num2 .real ;
div imag = num 1. imag /num 2 .imag ;
cout <<“\n Division of two real no. is = “
<<div .real <<“+I “<<div .imag ;
}
Wap to print division secured by
the student .
# include <iostream.h>
#include<stdio.h>
Void main ( )
{
int marks ;
clrscr ( ) ;
printf (“Enter the percentage of marks of student “)]
scanf (“%d” ,& marks ) ;
if (marks >=75)
{
printf (“Distinction”) ;
printf(“\n”) ;
}
else if (marks >=60 && max <75)
{
print (“first Division “);
print (“\n”) ;
}
else if (marks >=45 && mark <60 )
{
printf (“second division “ ) ;
print(“\n”) ;
}
else
{
printf(“FAIL”) ;
}
getch( ) ;
}
Wap that reads a password and prints
“OK”if the correct password is
entered ,otherwise print “SORRY!”.
#include<iostream.h>
#include <string.h>
#include<conio.h>
Int main( )
{
clrscr( );
char pass[20];
for(int i=0;i<3;i++)
{
cout<<“\nEnter password \n” ;
cin.getline(pass,20) ;
if (strcmp(pass,”PACE”))
cout<<“sorry incorrect password !!!\n” ;
else
{ cout<<“o.k.\n” ;
break ;
}
}
return 0 ;
}
Output
Enter the percentage of marks of student
70
first Division
operations and perform according to user’s
response.
#include<iostream.h>
#include<Lmath.h> //for sqrt ( ) function
# include <process.h> //for Exit function
int main ( )
{ char ch ‘ ch1 ;
float f ,perj ,area ;
cout<<“\n Square Menu “ ;
cout<<“\n 1. Area “ ;
cout<<“\n 2. Perimeter” ;
couut<<“\n 3.Exit”<<“\n” ;
do
{ cin>>ch ;
if(ch = =‘1’|| ch = = ‘2’)
{ cout <<“Enter length & breadth :” ;
cin>>s ;
}
switch (ch)
{ case ‘1’: area =s* s ;
cout<<“Area =“<<area ;
break ;
case ‘2’ : peri = 4* side
cout<<“Perimeter = “<<peri ;
break ;
case ‘3’ : cout << “Breaking” ;
exit ( 0) ;
default : cout <<“Wrong choice !!!!” ;
cout <<“Enter a valid one “ ;
break ;
} //end of switch .
cout<<“\n Want to enter more (y/n)?” ;
cin>> ch1 ;
if(ch 1 = = ‘y’ || ch1 = = ‘Y’)
cout <<“Again enter choice (1-4) :” ;
} while (ch1 = =‘y’|| ch1 = = ‘Y’ ) ; // end of DO loop
return 0 ;
}
Output
Square Menu
1. Area
2. Perimeter
3. Exit
Enter your choice :1
Enter side : 6
Area = 36
Want to enter more(y/n) ? Y
Again enter choice (1-3) : 2
Enter side : 6
Diagonal = 24
Want to enter more (y/n)? N
Program to show handicap of
call by value method .
# include<iostream.h>
# include <conio.h>
int main ( )
{ clrscr ( ) ;
void swap (int ‘ int ) ; //Swap takes two integers and return no values .
int a, b ;
a= 7 ;
b=4;
cout <<“\n original values are : \n” ;
cout <<“a =“<<a<<“ ,b =“ <<b <<“\n” ;
getch( ) ;
return 0 ;
}
void swap (int x , int y )
{
int temp ;
temp = x ;
x=y;
y = temp ; //values swapped .
cout <<“\n Swapped values are :” ;
cout <<“a=“<< x <<“ , b = “ << y << “\n” ;
}
Output
Original values are :
a =7 , b = 4
Swapped values are : a =4 ,b = 7
The values after swap ( ) are :
a=7,b=4
Program to calculate and print the sums of
even and odd integers of the first n
nautural numbers.
#include<iostream.h>
int main()
{
int n, sum_even=0, sum_odd=0,ctr=1;
cout <<“upto which natural number?”;
cin >> n ;
while (ctr <= n)
{
if (ctr % 2 = =0) //number is even
sum_even += ctr ;
else
sum_odd += ctr ;
c++ ; //increment the counter
} //end of while
cout <<“\n”<<“The sum of even integers is” <<sum_even ;
cout <<“\n”<< The sum of odd integers is”<< sum__odd ;
return 0 ;
}
Output
Upto which natural number ? 25
The sum of even integers is 156
The sum of odd integers is 169
WAP to find whether a given number is
odd or even or prime . The program
should continue as the user wants.
# include <iostream.h>
int main ( )
{
char ch ;
int num, I ;
do
{
cout<<“Enter a number \n” ;
cin>> num ;
if(num % 2 = =0)
cout<<“Even \n”;
else
cout<<“odd\n”;
if(num = = 1)
cout <<“Prime\n”;
else
{
for(i=2; i <=num/ 2;++i)
if(num % i = = 0)
{
cout <<“Not prime \n”;
goto lb ;
}
cout << “Prime \n”;
}
lb:
cout << “\n Want to continue (y\n) ?”;
cin >> ch ;
} while(ch ==‘y’ || ch == ‘Y’) ;
return 0 ;
}
Output
Please note to stop enterXXX
1.Enter name of the country => India
2.Enter the name of the city =>Delhi
1.Enter name of the country =>Germany
2.Enter the name of the city =>Denmark
1. Enter the name of the country =>France
2.Enter the name of the city =>Paris
1.Enter name of the country =>Pakistan
2.Enter the name of the city =>Lahore
Enter name of the country =>XXX
Enter the name of the country whose city is required: Pakistan
The city for the given country is Lahore
Output
MAME EMP NO. BASIC TOTAL
Nikhil 1 2900000 2900670
Rohit 2 3500000 3500760
Aarish 3 4700000 4700670
Highest salary :24054
Employee number is: 2
Output
Cost /unit (Rs.) Quantity
50 3
25 6
46 7
68 3
56 1
34 9
55 7
12 1
23 4
35 6
Output
Enter the real part of first complex number : 4
Enter the imaginary part of first complex number : 6
Enter the real part of second complex number : 2
Enter the imaginary part of second complex number : 3
Product of two real numbers is = 8+ i18
Division of two real numbers is = 2 +i2
Output
Enter first matrix 1 2 3
456
789
246
Enter second Matrix 4 6 8
357
135
785
The Resultant array is
5 8 11 7
10 13 8 11
14 9 12 11
Output
Enter password
123

Sorry incorrect password !

Enter password
PACE
Output
Enter the array
45 99 76
The second max. element of the matrix:99
St. Mary’s sen. Sec
School
Topic: C++
Class: 11th A

Submited to: Submited by:


Miss NOOREEN ZAIDI Tanisha Solanki
&
Pragya singh
Output
How many days in the month ?
5
Enter noon day temperature for day 1 23
Enter noon day temperature for day 2 22
Enter noon day temperature for day 3 24
Enter noon day temperature for day 4 25
Enter noon day temperature for day 5 26
Average temp:24 max. temp:26
Min. temp:22

You might also like