Wednesday, February 8, 2023

12th CMS Practicals Solutions 2023 || Computer Science 2023 || By Ashok Roshan Sir! || Class-12

1) Write a program in C+ to print 1+2+3+4+5+6...n terms using while loop.

#include<iostream.h>

#include<conio.h>

void main()

{

 int i,n,s=0;

 clrscr();

  cout<<"\nEnter any terms ";

 cin>>n;

 

 i=1;

 while(i<=n)

 {

  cout<<" "<<i;

  s=s+i;

  i++;

 }

 

 cout<<"\nSum of series = "<<s;

 

 getch();

 

}

2) Write a program in C++ to count number of characters in a given text.

#include<iostream.h>

#include<conio.h>

#include<stdio.h>

#include<string.h>

void main()

{

 int i,c=0;

 char str[100];

 clrscr();

 

 cout<<"\nEnter any text ";

 gets(str);

 

 for(i=0;str[i]!='\0';i++)

 {

  if(str[i]!='')

  {

   c++;

  }

  cout<<"\nTotal number of character = "<<c;

 getch();

 

}

3) Write a program in c++ to accept three integers and print the largest of three.

 

4) Write a program in c++ of Temperature conversion that gives the user the option of converting Fahrenheit to Celsius or Celsius to Fahrenheit depending upon user's choice.

 

#include<iostream.h>

#include<conio.h>

#include<stdio.h>

#include<string.h>

void main()

{

 int choice;

 float c,f;

 clrscr();

 

 cout<<"\n1 Fahrenheit to Celsius ";

 cout<<"\n2 Celsius to Fahrenheit  ";

 

 cout<<"\nEnter any choice ";

 cin>>choice;

 

 

 switch(choice)

 {

 

  case 1 : cout<<"\nEnter Temperatue in Faherenheit ";

         cin>>f;

         c=((f-32)*5)/9;

         cout<<"\nTemperatur in Celsius "<<c;

         break;

 

  case 2 : cout<<"\nEnter Temperature in Celsius ";

         cin>>c;

         f=(c*9/5)+32;

         cout<<"\nTemperature in Fahrenheit "<<c;

 

         break;

  default : cout<<"\nInvalid choice";

 }

 

 

 getch();

 

}

5) Given the Club Relation in the following table. Write SQL Commands for given questions:-

 

club

coachid

coachname

age

sports

dateofapp

pay

sex

1

Ravindra

35

Karate

27-Mar-96

1000

M

2

Puja

34

Karate

20-Jan-98

1200

F

3

Bhushan

34

Squash

19-Feb-98

2000

M

4

Akela

33

Basketball

01-Jan-98

1500

M

5

Suraj

36

Swimming

12-Jan-98

750

M

6

Rashmi

36

Swimming

24-Feb-98

800

F

11

Archana

37

Squash

25-Feb-98

2500

F

 

a) To show all information about the karate coaches in the club.

 select * from club where sports='karate'

Query1

coachid

coachname

age

sports

dateofapp

pay

sex

1

Ravindra

35

Karate

27-Mar-96

1000

M

2

Puja

34

Karate

20-Jan-98

1200

F

 

b) To list names of all coaches with their date of appointment in ascending order.

select coachname,dateofapp from club

order by dateofapp asc

 

Query2

coachname

dateofapp

Ravindra

27-Mar-96

Akela

01-Jan-98

Suraj

12-Jan-98

Puja

20-Jan-98

Bhushan

19-Feb-98

Rashmi

24-Feb-98

 

c) To display a report showing coach name, pay, age and bonus (20% of pay) for all the coaches.

SELECT coach name, pay, age , (pay*20/100) as bonus from club;

Query3

coachname

pay

age

bonus

Ravindra

1000

35

200

Puja

1200

34

240

Bhushan

2000

34

400

Akela

1500

33

300

Suraj

750

36

150

Rashmi

800

36

160

 

d)insert a new row in the club table.

insert into club values(11,"Archana",37,"Squash",25/02/1998,2500,"F")

 

e) i) select count(distinct sports) from club                         | 4

e) ii) select min(age) from club where sports=”karate”                | 34

e) iii)select avg(pay) from club where sports=”karate”                  |  1100

 

 

No comments:

Post a Comment

JAC Board Computer || IIT 2025 || Introductory Information Technology || Class 10 || Practical Examination 2025

Marks Division HOE 30 Marks IT Application Report File 20 Marks Viva - Voce 10 Marks 1) Write an HTML code to generate a web p...