Showing posts with label computer science. Show all posts
Showing posts with label computer science. Show all posts

C++ program to illustrate passing of structures by value.

Sunday, August 12, 2012


Write a C++ program to illustrate passing of structures by value. 

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct distance{
 int feet;
 int inches;
};
int main()
{
clrscr();
    distance length1, length2;
void prnsum(distance l1, distance l2);
cout<<"\n"<<"Enter length 1:\n";
cout<<"\n"<<"Feet:\n";
cin>>length1.feet;
cout<<"\n"<<"Inches:\n";
cin>>length1.inches;
cout<<"\n"<<"\n"<<"Enter length 2:\n";
cout<<"\n"<<"Feet:\n";
cin>>length2.feet;
cout<<"\n"<<"Inches\n";
cin>>length2.inches;
prnsum(length1, length2);
return 0;
}
void prnsum(distance  l1, distance l2)
{
  distance l3;
  l3.feet = l1.feet + l2.feet + (l1.inches +l2.inches)/12;
  l3.inches =( l1.inches + l2.inches)%12;
  cout<<"\n"<<"\n";
  cout<<"\n"<<"Total Feet:"<<l3.feet<<"\n";
  cout<<"\n"<<"Total Inches:"<<l3.inches;
  return;
}
/*
OUTPUT
------

Enter length 1:

Feet:
10

Inches:
1

Enter length 2:

Feet:
12

Inches
2

Total Feet:22

Total Inches:3


*/

CBSE SAMPLE PAPERS 2012

Wednesday, August 1, 2012

Click the links below to view.

C++ Program


Write a C++ Program to store information of 10 employees and to display information of an 
employee depending upon the employee no.


#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct addr
{
int houseno;
char area[30];
char city[30];
char state[30];
};
struct emp
{
int empno;
char name[30];
char desig[30];
addr address;
float basic;
}worker;
emp sales_emp[10];
void display(int a);
void enter(void);
int main()
{
clrscr();
int eno,i;
char ch;
enter();
do
{
cout<<"\n Enter the employee no. whose information is to be displayed:";
cin>>eno;
int flag=0;
for(i=0;i<2;i++)
{
if(sales_emp[i].empno==eno)
{
display(i);
flag=1;
break;
}
}
if(!flag)
{
cout<<"\n sorry! no such employee found";
}
cout<<"\n display more...(y/n)\n";
cin>>ch;
}while(ch=='y');
getch();
return 0;
}
void enter(void)
{
for(int i=0;i<2;i++)
{
cout<<"\n employee no:";
cin>>sales_emp[i].empno;
cout<<"\n name:";
gets(sales_emp[i].name);
cout<<"\n designation:";
gets(sales_emp[i].desig);
cout<<"\n * address *";
cout<<"\n house no:";
cin>>sales_emp[i].address.houseno;
cout<<"\n area:";
gets(sales_emp[i].address.area);
cout<<"\n city:";
gets(sales_emp[i].address.city);
cout<<"\n state:";
gets(sales_emp[i].address.state);
cout<<"\n basic pay:";
cin>>sales_emp[i].basic;
cout<<"\n\n";
}
return;
}
void display(int a)
{
cout<<"\n employee data";
cout<<"\n enployee no.:"<<sales_emp[a].empno;
cout<<"\n name:";
cout.write(sales_emp[a].name,30);
cout<<"\n designation:";
cout.write(sales_emp[a].desig,30);
cout<<"\n address:"<<sales_emp[a].address.houseno;
cout<<" \n";
cout.write(sales_emp[a].address.area,30);
cout<<" \n";
cout.write(sales_emp[a].address.city,30);
cout<<" \n";
cout.write(sales_emp[a].address.state,30);
cout<<" \n";
cout<<"\n basic pay:"<<sales_emp[a].basic;
cout<<"\n\n";
return;
}

C++ Program

Tuesday, July 31, 2012


Write A C++ Program To Read Values Into A Nested Stucture. 


#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct addr
{
int houseno;
char area[30];
char city[30];
char state[30];
};
struct emp
{
int empno;
char name[26];
char desig[26];
addr address;
float basic;
}worker;
int main()
{
clrscr();
cout<<"\n enter employee no.:\n";
cin>>worker.empno;
cout<<"\n name:\n";
gets(worker.name);
cout<<"\n enter designation:\n";
gets(worker.desig);
cout<<"\n enter address:\n";
cout<<"\n house no.:\n";
cin>>worker.address.houseno;
cout<<"\n area:\n";
gets(worker.address.area);
cout<<"\n city:\n";
gets(worker.address.city);
cout<<"\n basic pay:\n";
cin>>worker.basic;


cout<<"\n ***********\n";
cout<<"\n employee no.:\n ";
cout<<worker.empno;
cout<<"\n name:\n ";
puts(worker.name);
cout<<"\n designation:\n ";
puts(worker.desig);
cout<<"\n :address:\n ";
cout<<"\n house no.:\n ";
cout<<worker.address.houseno;
cout<<"\n area:\n ";
puts(worker.address.area);
cout<<"\n city:\n ";
puts(worker.address.city);
cout<<"\n basic pay:\n ";
cout<<worker.basic;
getch();
return 0;
}

COMPUTER SCIENCE: SQL

Tuesday, June 23, 2009

Some SQL queries for you to solve.....
Consider the table given below and write the commands:




1.TABLE : EMPEMPNO NUMBER(4), ENAME VARCHAR2(10),JOB VARCHAR2(9), MGR NUMBER(4), HIREDATE DATE,SAL NUMBER(7,2),COMM NUMBER(7,2),DEPTNO NUMBER(2)


(a) To display the name, hiredate of all the employee hired after employee Jan 10th 1980.
(b) To display the highest and lowest salary for each department.

(c) To display the name of the employees whose job is in Clerk, Salesman, President
(d) To display all the types of jobs available in EMP table without repeating any.
(e) To display the name and salary of all the employees in the alphabetical order of name.



2.TABLE : EMPEMPNO NUMBER(4), ENAME VARCHAR2(10),JOB VARCHAR2(9), MGR NUMBER(4), HIREDATE DATE,SAL NUMBER(7,2),COMM NUMBER(7,2),DEPTNO NUMBER(2)


To display the ename, deptno and salary of all employee who do not get commission.
To count the number of employees in each department.
To display the ename and hiredate of all the employees whose name start with A.
To display the name, department number for all employees who work as Clerks and earns a salary more than 4000
To display the employee number and employee name in the descending order of salary.



3.TABLE : EMPEMPNO NUMBER(4), ENAME VARCHAR2(10),JOB VARCHAR2(9), MGR NUMBER(4), HIREDATE DATE,SAL NUMBER(7,2),COMM NUMBER(7,2),DEPTNO NUMBER(2)


(a) Display all the records (all columns) from table Emp.
(b) Display the difference of highest and lowest salary of each department
(c ) Display Ename, Sal and Sal added with Comm from table Emp.
(d) Display Ename with heading “Employee”, Sal*12 as “Total Salary” from table Emp.
(e) Display distinct Sal of employees from table Emp




4.TABLE : EMPEMPNO NUMBER(4), ENAME VARCHAR2(10),JOB VARCHAR2(9), MGR NUMBER(4), HIREDATE DATE,SAL NUMBER(7,2),COMM NUMBER(7,2),DEPTNO NUMBER(2)


1. Show the Structure of table EMP
2. Write a query to display EName and Sal of Employees whose salary isgreater than or equal to 3000 in ascending order of employee name.
3. Write a Query to display empno, employee name and department numberof all employees who have manager number between 7500 and 7900.
4. Write a Query to display name, job, salary, and HireDate of employeeswho are hired between February 20, 1981, and May 1, 1981. Order thequery in ascending order of HireDate.
5. Write a Query to display the name of employee whose name contains ‘T’as the last alphabet.

COMPUTER SCIENCE: PROGRAMMING IN C++

Here are a few C++ practical questions based on stacks, queues and binary files.
1.A queue containing telephone number is to be implemented using a linked list. Write a menu driven program using an object to insert a telephone number in the queue and to delete a telephone number from the queue


2.WAP using binary file create a book file for writing title, author, publisher and year. Display the file contents and perform search operation for a given title


3.A queue containing telephone number is to be implemented using a linked list. Write a menu driven program using an object to insert a telephone number in the queue and to delete a telephone number from the queue.


4.Write a program in C++ to create a binary file “House.dbf” with the following structure : Name, Class, Section and House and to do the following functions :
i) To append a record.
ii) To delete all class 12 records.
iii) To display all the records.


5.Consider a file ITEM.DAT with the following information:INo, IName, Qty, Rate, AmountInclude functions to perform the following:
a).Append records.
b) Modify the record in INo.
c).Display the record.


6.Consider a file EMP.DAT with the following information.Empname, Empno, salary, dept.Include the functions for the following operations
a).Append records.
b).Delete a record on empno.
c). Display all records.


7.A queue containing telephone number is to be implemented using an array. Write a menu driven program to insert a telephone number in the queue and to delete a telephone number from the queue.


{P.S. Pls. request if you need the solution for the above questions and specify the question no. }


8.Write a program in C++ to demonstrate PUSH, POP and display operations on a Array implementation of stack containing Roll no of students.

Blogroll

Bookmark and Share
Powered By Blogger
CBSE 12th Grader.