Full course of c++ programming language
Click here > C++ programming language
Q-1 [A] Write a c program to create structure of employee with members Empid, EmpName, Qualification and EmpSalary by taking input of 5 employees display the employee whose qualification is "MBA" and salary greater than 20000.
#include <stdio.h>
#include <conio.h>
#include <string.h>
struct Employee
{
int Empid, EmpSalary;
char EmpName[50];
char Qualification[50];
};
Void main()
{
struct Employee emp[5];
int i;
for (i = 0; i < 5; i++)
{
printf("Enter employee ID: ");
scanf("%d", &emp[i].Empid);
printf("Enter employee name: ");
scanf("%s", emp[i].EmpName);
printf("Enter employee qualification: ");
scanf("%s", emp[i].Qualification);
printf("Enter employee salary: ");
scanf("%d", &emp[i].EmpSalary);
}
printf("\nEmployees with qualification of MBA and salary greater than 20000:\n");
printf("\nEmpId\tName\tQualification\tSalary\n");
for (i = 0; i < 5; i++)
{
if (strcmp(emp[i].Qualification, "MBA") == 0 && emp[i].EmpSalary > 20000)
{
printf("\n%d\t%s\t%s\t%d", emp[i].Empid, emp[i].EmpName, emp[i].Qualification, emp[i].EmpSalary);
}
}
getch();
return 0;
}
Q-1 [B] Write a python program to print sum of N numbers using UDF.
def num(n):
sum = 0
for i in range(1, n+1):
sum += i
return sum
n = int(input("Enter a number: "))
result = num(n)
print("The sum of first", n, "numbers is:", result)
Q-2 [A] Create following tables with proper constraints and insert atleast 5 records in each Table.
Course (course id, course name) Student(sno,sname,city,mobile,birth date.course_id) Perform following tasks:
1. Display student's detail with course name.
2. Display student's detail who belongs to " BCA" course.
3. Display total numbers of student's course_name wise.
4. Display student's detail as per city in ascending order along with course details.
5. Display student's detail whose birth__ date is before 2000.
CREATE TABLE Course
(
course_id number primary key,
course_name VARCHAR(50)
);
CREATE TABLE Student
(
sno number primary key,
sname VARCHAR(50) ,
city VARCHAR(50) ,
mobile VARCHAR(20) ,
birth_date DATE,
course_id number,
Constraint a FOREIGN KEY (course_id) REFERENCES Course(course_id)
);
1. Display student's detail with course name.
SELECT s.sno, s.sname, s.city, s.mobile, s.birth_date, c.course_name
FROM Student s
INNER JOIN Course c ON s.course_id = c.course_id;
2. Display student's detail who belongs to " BCA" course.
SELECT s.sno, s.sname, s.city, s.mobile, s.birth_date
FROM Student s
INNER JOIN Course c ON s.course_id = c.course_id
WHERE c.course_name = 'BCA';
3. Display total numbers of student's course_name wise.
SELECT c.course_name, COUNT(*) as total_students
FROM Student s
INNER JOIN Course c ON s.course_id = c.course_id
GROUP BY c.course_name;
4. Display student's detail as per city in ascending order along with course details.
SELECT s.sno, s.sname, s.city, s.mobile, s.birth_date, c.course_name
FROM Student s
INNER JOIN Course c ON s.course_id = c.course_id
ORDER BY s.city ASC;
5. Display student's detail whose birth__ date is before 2000.
select * from student where to_char(bdate,'yyyy')<2000;
Comments
Post a Comment