Wednesday 21 October 2020

Windows Programming MCQs

 

Windows Programming MCQs

1.      ________ enables one to explore the resources of Windows:



a.       API

b.      CPP

c.       MFC

d.      ATL



2.      Which application  we will use to make program more portable:



a.       WindowsAPI

b.      WindowApp

c.       MFC

d.      None of these



3.      The Win32API supports:



a.       16-bit Windows

b.      32-bit Windows

c.       64-bit Windows

d.      All of these



4.      Win32Program utilizes a central function called:



a.       Main

b.      App

c.       WinMain

d.      None of these



5.      The arguments of the WinMain() function are mandatory and it communicate with:



a.       Operating System

b.      Hardware

c.       Kernel

d.      None of these



6.      Which is the parameter of the WinMain():



a.       HInstance

b.      hPrecInstance

c.       LPSTR lpCmdLine

d.      Int nCmdShow

e.       All of these



7.      Which is used to install and configure the service application:



a.       Administration and Management

b.      Networking

c.       Archie

 

d.      Gopher



8.      ______ is done by pressing the restart button while the computer is on:



a.       Cold boot

b.      Warm boot

c.       Both a and b

d.      None of these



9.      ______ is done by pressing the power switch when it is turned off:



a.       Cold boot

b.      Warm boot

c.       Both a and b

d.      None of these



10.  What is the full form of BIOS-ROM:

a.       Basic Input Output System – Read Only Memory

b.      Binary Input Output System – Read Only Memory

c.       Binary Input Output System – Random Only Memory

d.      Basic Input Output System – Random Only Memory

 

 

11.  VRML stands for:

a.       Virtual Reality Model Language

b.      Virtual Reality Modeling Language

c.       Virtual Read-only Modeling Language

d.      Virtual Reality Mode Language

12.  HTML stands for:



a.       Hyper Text Meta Language

b.      High Text Markup Language

c.       Hyper Text Markup Language

d.      High Test Markup Language



13.  WPF stands for:

a.       Windows Presentation Function

b.      Windows Presentation Foundation

c.       Windows Procedure Foundation

d.      None of these

14.  WCF stands for:

a.       Windows Computer Foundation

b.      Windows Communication Foundation

c.       Windows Central Foundation

d.      None of these

15.  RPC stands for:



a.       Remote Presentation Call

b.      Radio Presentation Call

c.       Remote Procedure Call

d.      None of these



16.  SNMP stands for:

a.       Secure Network Management Protocol

b.      Simple Network Management Protocol

c.       Secured Network Management Procedure

d.       Simple Network Management Procedure

17.  HTTP stand for:

a.       Hyper Text Tele Protocol

b.      Hyper Text Transfer Protocol

c.       Hyper Text Transfer Procedure

d.      Hyper Tele Transfer Procedure

18.  FTP stands for:



a.       File Transaction Protocol

b.      File Transfer Protocol

c.       Format Transfer Protocol

d.      Formal Transfer Protocol



19.  DNS stands for:



a.       Domain Network System

b.      Domain Name System

c.       Data Name System

d.      Data Name Service



20.  BITS stands for:

a.       Binary Intelligent Transfer Service

b.      Background Intelligent Transfer Service

c.       Background Integrated Transfer Service

d.      Binary Integrated Text Service

21.  WWW stands for:



a.       World Web Wide

b.      World Wide Web

c.       Web Wide World

d.      None of These



22.  XML stands for:

a.       eXtensible Markup Language

b.      eXtra Markup Language

c.       eXtensible Mode Language

d.      None of these

23.  URI stands for:

a.       Universal Resource Identifier

b.      Uniform Resource Identifier

c.       Uniform Resource Identification

d.      Universal Resource Identification

24.  TCP/IP stands for:

a.       Transfer Control Protocol / Internet Protocol

b.      Transmission Control Protocol / Internet Protocol

c.       Transfer Configuration Protocol / Internet Protocol

d.      None of these

25.  CSP stands for:

a.       Cryptographic System Provider

b.      Cryptographic Service Providers

c.       Computer Service Provider

d.      Cryptographic Service Protocol

26.  _________ is a standard by which internet names are translated to their corresponding IP addresses:



a.       DSP

b.      DSW

c.       DNS

d.      DLL



27.  ________ is supported by TCP/IP client accessing Web document on Web server:



a.       Web Browsers

b.      Operating System

c.       Windows

d.      None of these



28.  What is return type of InitInstance:



a.       bool

b.      int

c.       char

d.      double



29.  In Win32 which function is used to create application:



a.       WinMain

b.      WinApp

c.       WinAPI

d.      None of these



30.  Security protects the data from:



a.       Authorized accessing

b.      Unauthorized accessing

c.       Administrator accessing

d.      None of these



31.  Which function handle the key container:



a.       CryptoAPI

b.      CryptAcquireContext

c.       CAPICOM

d.      CryptoGraphics



32.  The MFC library is a predefined set of:



a.       Data types

b.      Function

c.       Classes

d.      Constant

e.       All of these



33.  Which class is used to display something on screen:



a.       CWinApp

b.      MFC

c.       CWinAPI

d.      None of these



34.    Which function is provide by CWinApp to display something on screen:



a.       Start()

b.      Load()

c.       Close()

d.      InitApplication()



35.  Where the fundamental  classes of MFC are declared:



a.       afxwin.h

b.      include.h

c.       graphics.h

d.      conio.h



36.  What is included by frame of window:



a.       Location

b.      Dimension

c.       Borders

d.      All of these



37.  Which class is used by MFC to create the frame:



a.       CMainFrame

b.      CFrameWnd

c.       CMainWnd

d.      None of these



38.  Which class is used to create a Window frame:



a.       CFrameWnd

b.      CMainFrame

c.       CMainWnd

d.      None of these



39.   Which function is associated with window frame:



a.       InitApp()

b.      Stop()

c.       Destroy()

d.      Create()



40.  Which is the base class of CWinApp:



a.       CWinThread

b.      CWin

c.       CWin_Tread

d.      CThread



41.  Which function is called to display the frame in resultant window:



a.       CloseWindow()

b.      ShowWindow()

c.       DeleteWindow()

d.      None of these



42.  Which file is required to export the DLL function:



a.       A.def

b.      A.dll

c.       A.exe

d.      None of these



43.  Which function is used to create DLL files:****



a.       DllMain

b.      DefMain

c.       Main

d.      Void_main



44.   Which keyword is used to declare the variable and function to specify the external link:



a.       extern

b.      void

c.       this

d.      new



45.  Which macro is used to handle the command message:



a.       ON_COMMAND

b.      ON_LBUTTONDOWN

c.       ON_RBUTTONDOWN

d.      ON_LBUTTONDBLCLK



46.  Which class is used to handle the windows message and control notification:



a.       CWnd

b.      CFrameWnd

c.       CMDIFrameWnd

d.      CView



47.   Which classes are included by CWnd class:



a.       CFrameWnd

b.      CMDIFrameWnd

c.       CView

d.      CMDIChildWnd

e.       All of these



48.  MVC stands for:

a.       Model View Controller

49.  Which  key events are identified by wParam:



a.       Shift

b.      Ctrl

c.       Both a and b

d.      None of these



50.  Which class is provided by MFC library:



a.       CScrollView

b.      CView

c.       CFrame

d.      None of these



51.  Web browser can access:



a.       Client computer

b.      Application Programs

c.       Web Pages

d.      All of these



52.  Which protocol is supported by web browser:



a.       TCP/IP

b.      IP

c.       TCP

d.      All of these



53.  A browser can support:



a.       Hyper Text

b.      Images

c.       Sound Files

d.      Flash Animations

e.       All of these



54.  Security is implemented by:



a.       Crypto API

b.      Cryptographic Service Providers

c.       CAPICOM

d.      All of these



55.  Security protects data from:



a.       Fire

b.      Flood

c.       Unauthorized access

d.      Authenticated user



56.  CSP contains a key that is stored in….



a.       Web Browser

b.      Text files

c.       Encrypted files

d.      Key Database



57.  The parameters for Create() function are:



a.       LPCTSTR lpszClassName

b.      LPCTSTR lpszWindowName

c.       DWORD dwStyle

d.      lpszMenuName

e.       All of these



58.  Which function is essential for DLL files:



a.       DllMain

b.      DefMain

c.       VoidMain

d.      Main



59.  Parameter contains:



a.       ID

b.      wParam

c.       lParam

d.      All of these



60.  Which is the Scroll message handler:



a.       WM_VSCROLL

b.      WM_HSCROLL

c.       Both a and b

d.      None of these



61.  Which is the base class for Bitmap:



a.       CBitmap

b.      CView

c.       CScrollView

d.      None of these



62.  Which function load bitmap image into CBitmap object:



a.       LoadBitmapW

b.      StartBitmap

c.       DeleteBitmap

d.      None of these



 

63.  Which function is used to get size of scrolls:

a.       GetDeviceScrollSizes()

64.  Which is the parent of all MFC view classes:



a.       CDocView

b.      CTableView

c.       CScrollView

d.      CView



65.  The nMapMode argument holds a mapping mode that is:



a.       MM_TEXT

b.      MM_HIMETRIC

c.       MM_TWIPS

d.      MM_HIENGLISH

e.       All of these



66.   _______ handles the connections from client and can provide several independent screens:



a.       Client

b.      Server

c.       Both a and b

d.      None of these



67.  What is required to provide the control for X server:



a.       Client’s hostname

b.      IP address

c.       Both a and b

d.      None of these



68.  By which program we can manipulate the access control list:



a.       Xhost

b.      Xhost+hostname

c.       Xhost-hostname

d.      None of these



69.  We can add a host to the list with:



a.       Xhost

b.      Xhost+hostname

c.       Xhost-hostname

d.      None of these



70.  We can remove host from the list with:



a.       Xhost

b.      Xhost+hostname

c.       Xhost-hostname

d.      None of these



71.  DECNET stands for:

a.       Digital Equipment Corporation Networking

72.  X contains:



a.       X Protocol

b.      X Display Server

c.       X Client

d.      Xlib routines



e.       All of these

73.  X was developed to create a platform-independent network-based:



a.       A complete OS

b.      Graphical User environment

c.       Both a and b

d.      None of these



74.  The X window protocol has the server that provides the ________ windowing mechanism:



a.       Advance basic

b.      Advance

c.       Basic

d.      None of these



75.  Server handles the connections from ________ and can provides several independent screens:



a.       Other servers

b.      Clients

c.       Internet

d.      None of these



76.  The function of the X Window is:



a.       Establish a connection with the X server

b.      Create a window

c.       Create X resources

d.      Wait, detect and perform event

e.       All of these



77.  The X windows system is GUI and is entirely based on:



a.       Microsoft Windows

b.      Macintosh Operating System

c.       Both a and b

d.      None of these



78.  The X-Term terminal emulator and the user interface that supports:



a.       Window

b.      Mouse

c.       Keyboard

d.      All of these



79.  It is used to listen to the network connections at a specific port is called:



a.       X Client

b.      X Server

c.       X Window

d.      X application



80.  X Server supports:



a.       Single Window Mode

b.      Multiple Window Mode

c.       Both a and b

d.      None of these



81.  Which network protocol is supported by X:



a.       TCP/IP

b.      DECNET

c.       STREAMS

d.      All of these



82.  Which variable is used to determine where the x server is located:



a.       Display

b.      Search

c.       Both a and b

d.      None of these



83.  What is the name of function that is added for WM_KEYDOWN:



a.       OnKeyDown

b.      OnKeyUp

c.       Both a and b

d.      None of these



84.  Which is the parameters / arguments of OnKeyDown function:



a.       nChar

b.      nRepCnt

c.       nFlags

d.      All of these



85.  Which function is used to set cursor:

a.       SetCursor

86.  In OnKeyDown which argument represent the number of times of key pressing:



a.       nChar

b.      nRepCnt

c.       nFlags

d.      None of these



87.   Which argument keeps a combination flag that checks whether key is being pressed at the same time with the other keys:



a.       nChar

b.      nRepCnt

c.       nFlags

d.      None of these



88.  The Class Wizard is use function for WM_SETCURSOR message:

a.       OnSetCursor

89.  To register your own window class containing the desired mouse pointer by using:



a.       AfxRegisterClass()

b.      AfxRegisterWndClass()

c.       Both a and b

d.      None of these



90.  Which class refers to the co-ordination point of screen:

a.       CPoint

91.  In which namespace cursor are stored:

a.       Cursor namespace

92.  Which is the property of the panel control:



a.       Location

b.      Size

c.       Border Style

d.      Cursor

e.       All of these



93.  Which is the protective mechanism that lies between the computer network and the Internet to protect from malfunctions and network-based security threats:



a.       Firewall

b.      Archie

c.       Finger

d.      Active attacks



94.  Which indicator represents the position of the mouse on a screen:



a.       Cursor

b.      Mouse

c.       Keyboard

d.      None of these



95.  Which program is used for searches files anywhere on the network by the filename:



a.       Archie

b.      Firewall

c.       Finger

d.      Active attacks

 

Fuzzy sets MCQs

 

CBSE NET Fuzzy sets Questions and Answers

Check the link below for more such questions
http://ugcnetsolved-computerscience.blogspot.in/?view=flipcard

1. How to denote a fuzzy set?
IF X is the universe of discourse and x is a particular element of X, then a fuzzy set A defined on X may be written as a collection of ordered pairs:
A={(x,µA(A))}, x belongs to X
The pair (x, µA(A)) is called a singleton.
In crisp sets, a singleton is simply the element x by itself.
In fuzzysets, a singleton is composed of two terms: x and µA(x).
A singleton is also written as µA(x)/x. That is by putting the membership function first followed by the ‘/’symbol and is used to separate the function from x.
Singletons whose membership to a fuzzy set is 0 may be omitted.

2. Union of two fuzzy sets
µAUB(x) = µA(x) V µB(x) = max(µA(x), µB(x))

3. Intersection of two fuzzy sets
µA Intersection B(x) = µA(x) ^ µB(x) = min(µA(x), µB(x))

4. Complement of a fuzzy set
The complement of a fuzzy set A is a new fuzzy set A Complement, containing all the elements which are in the universe of discourse but not in A, with the membership function
Complement of µA(x) = 1 - µA(x)

5. Height of a fuzzy set
The height of a fuzzy set is the highest membership value of the membership function:
Height(A) = max µA(xi)
A fuzzy set with height 1 is called a normal fuzzy set.
In contrast, a fuzzy set whose height is less than 1 is called a subnormal fuzzy set.

6. α-cut of a fuzzy set
α-cut of a fuzzy set A denoted as Aα, is the crisp set comprised of the elements x of a universe of discourse X for which the membership function of A is greater than or equal to α.

Solved problems from various NET papers.
JUNE 2012 – PAPER III Q.No 6
6. If two fuzzy sets A and B are given with membership functions μA(x) = {0.2, 0.4, 0.8, 0.5, 0.1} μB(x) = {0.1, 0.3, 0.6, 0.3, 0.2} Then the value of μ ––– will be A∩B
(A) {0.9, 0.7, 0.4, 0.8, 0.9}
(B) {0.2, 0.4, 0.8, 0.5, 0.2}
(C) {0.1, 0.3, 0.6, 0.3, 0.1}
(D) {0.7, 0.3, 0.4, 0.2, 0.7}
Ans:-A
Explanation:- The fuzzy intersection of two fuzzy sets A and B on universe of discourse X: μA∩B(x) = min [μA(x), μB(x)] , where xXBut here in the question, they are asking for complement of A intersection B and so the answer would be 1-min[A(x),B(x)].
The minimum of 0.2 and 0.1 will be 0.1, and 1-0.1 will be 0.9
The second value is min(0.4,0.3)=0.3 and 1-0.3=0.7
The third value is min(0.8,0.6)=0.6 and 1-0.6=0.4
The fourth value is min(0.5,0.3)=0.3 and 1-0.3=0.7
The last value is min(0.1,0.2)=0.1 and 1-0.1=0.9
The only option which has got the values 0.9,0.7,0.4,0.7 and 0.9, although the fourth value is given as 0.8 instead of 0.7 is option A.
So the answer is option A.

DECEMBER 2012 – PAPER III Q.No 13
13. Consider a fuzzy set A defined on the interval x=[0,10] of integers by the membership function.
µA(x) = x / x+ 2
α cut corresponding to α = 0.5 will be
(A) { 0,1,2,3,4,5,6,7,8,9,10}
(B) {1,2,3,4,5,6,7,8,9,10}
(C) {2,3,4,5,6,7,8,9,10}
(D) { }
Ans:- C
Explanation:-
In the fundamentals, refer to the answer given for question no. 6 regarding α-cut.
α-cut of a fuzzy set A denoted as Aα, is the crisp set comprised of the elements x of a universe of discourse X for which the membership function of A is greater than or equal to α.
Given, x = In the range [0,10]
Membership function = x/x+2
Calculate the value of membership function for the interval from 0 to 10, substituting in the formula x/x+2.
µA(0) = 0 / 0+ 2 = 0

µA(1) = 1 / 1+ 2 = 0.33

µA(2) = 2 / 2+ 2 = 0.5

µA(3) = 3 / 3+ 2 = 0.6

µA(4) = 4 / 4+ 2 = 0.66

µA(5) = 5 / 5+ 2 = 0.71

µA(6) = 6 / 6+ 2 = 0.75

µA(7) = 7 / 7+ 2 = 0.77

µA(8) = 8 / 8+ 2 = 0.8

µA(9) = 9 / 9+ 2 = 0.81

µA(10) = 10 / 10+ 2 = 0.83

α= 0.5. We have to find the corresponding α-cut,

That will be a crisp set, having those values of x, for which the membership function is returning a value of 0.5 or above.

µA(2) = 0.5 and all the values of x above 2 is getting a value greater than 0.5. So the crisp set will contain the following values.

{ 2,3,4,5,6,7,8,9,10}.

So the correct answer is C.


DECEMBER 2013 – PAPER III Q.No 28
28. If A and B are two fuzzy sets with membership functions μA(x) = {0.2, 0.5, 0.6, 0.1, 0.9} μB(x) = {0.1, 0.5, 0.2, 0.7, 0.8} Then the value of μA ∩B

will be

(A) {0.2, 0.5, 0.6, 0.7, 0.9}

(B) {0.2, 0.5, 0.2, 0.1, 0.8}

(C) {0.1, 0.5, 0.6, 0.1, 0.8}

(D) {0.1, 0.5, 0.2, 0.1, 0.8}

Ans:-D

Explanation:-

Intersection of two fuzzy sets

µA ∩B (x) = µA(x) ^ µB(x) = min(µA(x), µB(x))

μA(x) = {0.2, 0.5, 0.6, 0.1, 0.9}

μB(x) = {0.1, 0.5, 0.2, 0.7, 0.8}

μA ∩B={0.1,0.5,0.2,0.1,0.8}

So, the correct answer is D.


29. The height h(A) of a fuzzy set A is defined as h(A) =sup A(x) where x belongs to A. Then the fuzzy set A is called normal when

(A)h(A)=0

(B)h(A)<0

(C)h(A)=1

(D)h(A)<1

Ans:- C

Explanation:-

Explanation:- The height of a fuzzy set is the highest membership value of the membership function: Height(A) = max µA(xi)

A fuzzy set with height 1 is called a normal fuzzy set.

In contrast, a fuzzy set whose height is less than 1 is called a subnormal fuzzy set. So, according to the above rule, the fuzzy set A is called normal when h(A)=1.

So, the correct answer is 1.


JUNE 2013 – PAPER III Q.No 74
74. If A and B are two fuzzy sets with membership functions μA(x) = {0.6, 0.5, 0.1, 0.7, 0.8} μB(x) = {0.9, 0.2, 0.6, 0.8, 0.5}

Then the value of μ Complement AB(x) will be

(A) {0.9, 0.5, 0.6, 0.8, 0.8}

(B) {0.6, 0.2, 0.1, 0.7, 0.5}

(C) {0.1, 0.5, 0.4, 0.2, 0.2}

(D){0.1,0.5,0.4,0.2,0.3}

Ans:- C

Union of two fuzzy sets

µAUB
(x) = µA(x) V µB(x) = max(µA(x), µB(x))

μA(x) = {0.6, 0.5, 0.1, 0.7, 0.8}

μB(x) = {0.9, 0.2, 0.6, 0.8, 0.5}

µAUB(x) = {0.9,0.5,0.6,0.8,0.8}

Complement of µAUB(x)={0.1,0.5,0.4,0.2,0.2}

So, the correct answer is C.


JUNE 2014 – PAPER III Q.No 7,8 7. Given U = {1, 2, 3, 4, 5, 6, 7} A = {(3, 0.7), (5, 1), (6, 0.8)} then

~ A will be : (where ~ →complement)

(A) {(4, 0.7), (2, 1), (1, 0.8)}

(B) {(4, 0.3), (5, 0), (6, 0.2) }

(C) {(1, 1), (2, 1), (3, 0.3), (4, 1), (6, 0.2), (7, 1)}

(D) {(3, 0.3), (6.0.2)}

Ans:- C

Explanation:-

Complement of a fuzzy set

The complement of a fuzzy set A is a new fuzzy set A Complement, containing all the elements which are in the universe of discourse but not in A, with the membership function

Complement of µA(x) = 1 - µA(x)

Complement of a fuzzy set A is a new fuzzy set A complement. Since it is a fuzzy set, there will be two members in a singleton. The first member will be all the elements which are in the universe of discourse but not in A. The membership function will be 1- µA(x).

So, the complement of A will be

{(1,1),(2,1),(3,0.3),(4,1),(6,0.2),(7,1)}

The first is (1,1). The first 1 is in U but not in A, so it should be added in the complement. The second 1 is because the membership function is 1- µA(x). 1-0=1.

The same reason why you get (2,1).

The third one (3,0.3) because it is (3,1-0.7)=(3,0.3).

Same reason why you have (4,1) and (7,1).

(6,1-0.8)=(6,0.2).

The member (5,0) is not included because , a singleton whose membership to a fuzzy set is 0, can be excluded .


8. Consider a fuzzy set old as defined below

old={(20,0),(30,0.2),(40,0.4),(50,0.6),(60,0.8),(70,1),(80,1)}. Then the alpha-cut for alpha=0.4 for the set old will be (A){(40,0.3)}

(B){50,60,70,80}

(C){(20,0.1),(30,0.2)}

(D){(20,0),(30,0),(40,1),(50,1),(60,1),(70,1),(80,1)}

Ans:-D

Explanation:-

alpha-cut of a fuzzy set A will contain those elements where the membership function value is equal to or greater than alpha.

Here, alpha is given a value 0.4. Starting from (40,0.4) all the members have membership function equal or greater than 0.4. so, except

(20,0) and (30,0.2) all the menbers are included in the alpha-cut of the fuzzy set. The only option which has 40,50,60,70, and 80 included is option D. It has

(20,0) and (30,0) too. But it is already noted that any singleton where the membership function is 0 can be considered not included. So basically these two members are not part of the alpha-cut of the fuzzy set A. So the correct option is D.

 


Thursday 15 October 2020

Introduction to R programming using R studio-Beginner Basics

R is case sensitive
# is comment
(Rstudion Code menu->comment/Uncomment option)

To clear Rstudio console
Ctrl+L

To install package MASS
install.packages("MASS")

Alt hypen to get <- in R

to create a vector of 3 elements    
sample <- c(2,1,5.8)
captaincy <- data.frame(namesVector, YVector, playedVector)
1. create dataframe
2. access parts in dataframe
digits=2
mean(captaincy$y,ratio)
write.csv(captaincy,"Newcap.csv",row.names=FALSE)

newCap = read.csv("/../..1.csv")
View(newCap)

inbuilt dataset CO2

View(CO2)
> mean(CO2$conc)
[1] 435
> median(CO2$uptake)
[1] 28.3

> plot(CO2$Plant,CO2$uptake,type='l')


To check the packages installed in R type
library()

To load a package
library(MASS)

ctrl+shift+n to create new R script
ctrl+shift+enter in scipt window to run


Highlight a code and press ctrl+Enter to run only the selected part

sum(matrixA)
colSums(matrixA)
rowSums(matrixA)

To add new row in dataframe
captaincy <- rbind(captaincy, data.frame(name="kohli",Y=2016, played=30,won =20, lost =9,victory=20/30)

cbind is used to add new column to data frame

defeat=captaincy$lost/captaincy$played
captaincy<-cbind(captaincy,defeat)

CaptaincyOne <- read.csv("c.csv")
class(CaptaincyOne)
typeof(CaptaincyOne)  #to get to know about type of data
help(typeof)  #to know more about type of


head(CaptaincyOne,2) # top 2 rows will be displayed
tail(CaptaincyOne,2) # last 2 rows will be displayed
str(CaptaincyOne,2) # structural information  will be displayed


To merge two data frames
c<-merge(CaptaincyOne,CaptaincyTwo, by="names")

To read notepad file
t=read.table("one.txt")

Commonly used R objects are
1. vector
2. Lists
3. Matrices
4. Factors
5. Data Frames

Atomic vector types
logic
integer
numeric
complex 
character

Factor are often referred as categorical variables
Factors have levels

u can convert int to factors
f<factor(fa)

To display levels of factor variable f
levels(f)

as.matrix will convert into matrix

List can contain mixed data type elements
atomic vector has similar data type elements

my<-c(1:5)

list elements can be accesssed using index
mylist[[2]],[,3]  2nd row 3rd column

mylist[][3] indicates all rows 3rd column

to merge two lists l1 and l2
merge.list <- c(l1,l2)

To plot histogram
data <- read.csv("C:/Users/SARVANI/Desktop/rProjects/moviesData.csv")
dim(data)
hist(data$runtime, main = "Distibution of movies",xlab="runtime", xlim=c(0,300),col="blue"   )


to plot pie chart
g <- table(data$genre)
pie(g)

to plot barchart
barplot


conditional statements in C with example questions

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/dummy1-1/description/

decision making statements in c

Simple if:
Write a C Program to input Employee Id and basic pay of an employee and then print
Employee Id, HRA and Special allowance. Consider HRA is 20% of basic or Rs. 7000/ whichever
is less and Special allowance is 10% of basic pay whenever basic exceeds Rs 10000, Otherwise it
is 5% of basic pay.

if else:
Read in one character from the user (this may be 'Y', 'y', 'N', 'n'). If the character is 'Y' or 'y' display "YES". If the character is 'N' or 'n' display "NO". No other character will be provided as input.

https://www.hackerrank.com/challenges/30-conditional-statements/problem
Given an integer, , perform the following conditional actions:
  • If  is odd, print Weird
  • If  is even and in the inclusive range of  to , print Not Weird
  • If  is even and in the inclusive range of  to , print Weird
  • If  is even and greater than , print Not Weird
Nested if else:
Write a program to Prepare the current bill based on the following slab rates using conditional or Ternary operators, relational and logical operators. Find its time complexity.
Slab rate for below 500 units of consumption
Units
Slab rate per unit
Less than 250
1.45 Rs
Less than 500
2.60 Rs.
Slab rate for 500 units and above units of consumption
Units
Slab rate per unit
Less than 500
3.00 Rs.
500 and above
5.00 Rs.
]

Else if Ladder:

Each number on the telephone dial (except 0 and 1) corresponds to three alphabetic characters. Those correspondences are: 2 ABC 3 DEF 4 GHI 5 JKL 6 MNO 7 PRS 8 TUV 9 WXY Write a function to find the number dialled for given character. (10M)

#include<stdio.h>

void display(char ch)

{

if(ch=='A' || ch=='B' || ch=='C')

printf("2\n");

else if(ch=='D' || ch=='E' || ch=='F')

printf("3\n");

else if(ch=='G' || ch=='H' || ch=='I')

printf("4\n");

else if(ch=='K' || ch=='L' || ch=='M')

printf("5\n");

else if(ch=='N' || ch=='O' || ch=='P')

printf("6\n");

else if(ch=='Q' || ch=='R' || ch=='S')

printf("7\n");

else if(ch=='T' || ch=='U' || ch=='V')

printf("8\n");

else if(ch=='W' || ch=='X' || ch=='Y')

printf("9\n");

}

int main()

{

char ch;

printf("Enter a character:");

scanf("%c",&ch);

display(ch);

return 0;

}

A company decides to give bonus to all its employees on Diwali. A 5% bonus on salary is given to the male workers and 10% of bonus on salary to the female workers. Write a C function to read the salary and gender of the employee from a file. Calculate the bonus that must be given to the employee and display the salary that the employee will get.

Solution:

voidprintBonus()

{

float Salary,bonus;

char gender;

FILE *fp;

fp = fopen("Salary.txt","r");

scanf("%f %c",&Salary,&gender);

fclose(fp);

if(gender=='f'|| gender =='F')

bonus = 0.1*salary;

else

bonus = 0.05*salary;

printf("The Bonus: %f",bonus);

}

4) Design a flowchart to calculate the custom duty based on the following: Assume that imported goods from foreign countries are classified into 4 categories for imposing custom duty % of custom duty

Category on value of growth

1 10

2 15

3 17.5

4 25

Develop a program for current billing System based on the given requirements using if else
ladder.
Units Consumed Rate of Charge
0-200 Rs. 0.50 per unit
201- 400 Rs. 0.65 per unit in excess of 200 units
401- 600 Rs. 0.80 per unit in excess of 400 units
601 and above Rs. 1.00 per unit in excess of 600 units


calculates the fine (if any). The fee structure is as follows:
  1. If the book is returned on or before the expected return date, no fine will be charged (i.e.: .
  2. If the book is returned after the expected return day but still within the same calendar month and year as the expected return date, .
  3. If the book is returned after the expected return month but still within the same calendar year as the expected return date, the .
  4. If the book is returned after the calendar year in which it was expected, there is a fixed fine of .
Switch Case:
Write a program to read a number between 1 to 7 and then display its corresponding day name.
Write a program to input a digit and print it in words?

Write a C program print total number of days in a month using switch case.
Total days in a month is given by below table.
MonthTotal days
January, March, May, July, August, October, December31 days
February28/29 days
April, June, September, November30 days

#include <stdio.h> int main() { int month; /* Input month number from user */ printf("Enter month number(1-12): "); scanf("%d", &month); switch(month) { /* Group all 31 days cases together */ case 1: case 3: case 5: case 7: case 8: case 10: case 12: printf("31 days"); break; /* Group all 30 days cases together */ case 4: case 6: case 9: case 11: printf("30 days");
break; /* Remaining case */ case 2: printf("28/29 days"); break; default: printf("Invalid input! Please enter month number between 1-12"); } return 0; }
Write a C program to create Simple Calculator using switch case.
  1. #include <stdio.h>
  2. int main() {
  3. char operator;
  4. double n1, n2;
  5. printf("Enter an operator (+, -, *, /): ");
  6. scanf("%c", &operator);
  7. printf("Enter two operands: ");
  8. scanf("%lf %lf",&n1, &n2);
  9. switch(operator)
  10. {
  11. case '+':
  12. printf("%.1lf + %.1lf = %.1lf",n1, n2, n1+n2);
  13. break;
  14. case '-':
  15. printf("%.1lf - %.1lf = %.1lf",n1, n2, n1-n2);
  16. break;
  17. case '*':
  18. printf("%.1lf * %.1lf = %.1lf",n1, n2, n1*n2);
  19. break;
  20. case '/':
  21. printf("%.1lf / %.1lf = %.1lf",n1, n2, n1/n2);
  22. break;
  23. // operator doesn't match any case constant +, -, *, /
  24. default:
  25. printf("Error! operator is not correct");
  26. }
  27. return 0;
  28. }

C program to find maximum between two numbers using switch case
#include <stdio.h> int main() { int num1, num2; /* Input two numbers from user */ printf("Enter two numbers to find maximum: "); scanf("%d%d", &num1, &num2); /* Expression (num1 > num2) will return either 0 or 1 */ switch(num1 > num2) { /* If condition (num1>num2) is false */ case 0: printf("%d is maximum", num2); break; /* If condition (num1>num2) is true */ case 1: printf("%d is maximum", num1); break; } return 0; }

Practice Questions:
 Q. Write a C function that takes input as Salaesman-id, total sales amount of a salesman and prints salesman-id and his incentives. The incentives are,
1) 30% of total sales amount when total sales exceeds Rs. 50,000
2) 20% of total sales amount or Rs 8,000 whichever is less when total sales exceeds Rs. 20,000
3) 5% of total sales amount when total sales are less than 20,000

Q. Develop an algorithm and program to find the total bill amount in shopping mall by reading total amount for purchased grocery. Services and taxes are calculated as shown below
                            service tax        discount
1. if bill <=500         5%                    1%
2. if bill <=1500    10%                   5%
3. if bill <=2000     15%                 10%
4. if bill <=2500     20%                 15%
5. else                    25%                  20%

Q. A factory gives the following rates of commission for the monthly sales of its product        discount
sales                            Commission
below Rs 10000                No commission  
10011-15000                    5% commission
15001-20000                    7.5% commission
Above 20000                    10% commission 
Write a program to read the sales of individual customers and print their
commission and name of the customer

Q) Age calculator program to find the age.
If your date of birth is 28/07/2020 and u want to calculate your age as on 10/08/2021.
complete the month to get the date 01/08/2020...to complete the month we need to add
(31-28) days = 3 days.
To complete the year to get 01/01/2021, we need to add 12-(7+1)=12-8=4 months
To get get 10/08/2021 we need to add 10 days and 8 months to 01/01/2021.
So the age is 3+10 days and 4+8 months i.e, 1 year 13 days.


Q) Raju started learning programming and tries to solve at least one problem on his own.
He started solving the problem at 15:10 and completed it at 16:05.
How long did he take to solve the problem? (Give your answer in minutes).

Program:
#include<stdio.h> int calcMinutes(int sh,int sm, int eh, int em); int main() { int sh,sm,eh,em,answer; sh=15,sm=10,eh=16,em=5; answer=calcMinutes(sh,sm,eh,em); if(answer == -1) printf("invalid input"); else printf("minutes taken to solve the problem = %d minutes",answer); return 0; } int calcMinutes(int sh,int sm, int eh, int em) { if(eh==sh &&em>=sm) return em-sm; if(eh >sh) return (eh-(sh+1))*60+(60-sm)+em; return -1; }

Problem Comprehension:

 condition 1: if endingHoursis equal to startingHours then

endingMinutes must be >startingMinutes.

Ex: 15:10 and 15: 30 then answer=endingMinutes – startingMinutes = 30-10 = 20 minutes

·         condition 2: if endingHours>startingHours

      Ex:  15:10 and 18: 05 then 

          if the time is 15:10 then after 50 minutes it will be 16:00 ...60-startingMinutes

          now find the difference between 16:00 and 18:00 that is 2 hours i.e endingHours-(staringHours+1)

          add 5 minutes in 18:05

      so, formula= (endingHours-(staringHours+1))*60+(60-startingMinutes)+endingMinutes

Q

     Q) Meghana was filling application form for the job of Assistant professor in KLU. 

         The application requires the age of Meghana as on 08/2021. 

         If Meghana is born on 02/2005. What is the age in years she needs to fill in application form.