Skip to main content

Pratical -206 paper solution -3

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

Popular posts from this blog

C++ programming language

                c++ is a general programming language and is widely used nowadays for competitive programming. It has imperative, object-oriented and generic programming features.C++ runs on lots of platforms like Windows, Linux, Unix, Mac etc.   ❖❖  C++ with oops ❖❖

7. Switch Statement in c++

 ❖ C++ switch Statement :-                Consider a situation in which, only one block of code needs to be executed among many blocks. This type of situation can be handled using nested if...else statement but, the better way of handling this type of problem is using switch...case statement.  Syntax of switch:-      Switch(expression) {            Case value1 : statement1;                       Break;             Case value2 : statement2;                      Break;             Default : default statements;  }               The expression is either an integer or a character in above syntax. If the expression matches constant in case, the relevant codes a...

3. Input /output in c++

  ➢   Input/ Output in C++ :-        C++ comes with libraries which provides us many ways for performing input and output. In C++.        input and output is performed in the form of sequence of bytes or more commonly known as  streams. ● Input Stream: If the direction of flow of bytes is from device(for example: Keyboard) to the main memory then this process is called input. ● Output Stream: If the direction of flow of bytes is opposite, i.e. from main memory to device(display screen ) then this process is called output. ● Header files available in C++ for Input – Output operation are: • iostream: iostream stands for standard input output stream. This header file contains definitions to objects like cin, cout, cerr etc. • fstream: This header file mainly describes the file stream. This header file is used to handle the data being read from a file as input or data being written into the file as output.       ...