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 ❖❖

9. Jumps Statement in c++

➢ Jumps in Loops:- ➢ C++ break and continue Statement:-                     There are two statements (break; and continue ;) built in C++ programming to alter the normal flow of program.                     Loops are used to perform repetitive task until test expression is false but sometimes it is desirable to skip some statement/s inside loop or terminate the loop immediately with checking test condition. On these type of scenarios, continue; statement and break; statement is used respectively. The break; statement is also used to terminate switch statement. 1) break Statement :-                       The break; statement terminates the loop(for, while and do..while loop) and switch statement immediately when it appears . Syntax of break :- break;              ...