Sunday, October 23, 2016

C Language Input Output Formatting Function for BCA, BSc(IT) and PGDCA



Prepared By : Uday Shah - HOD (IT)
Contact No : 7600044051
--------------------------------------------------------------------------------------------------------------------------

I/O Formatting Functions

Printf() function :
·        Printf() function is use to display something on the console or to display the value of some variable on the console The general syntax for printf() function is as follows
printf(<”format string”>,<list of variables>);
·        To print some message on the screen
·        Printf(“God is great”);
·        This will print message “God is great” on the screen or console.
·        To print the value of some variable on the screen
int a=10;
printf(“%d”,a);
Here %d is format string to print some integer value and a is the integer variable whose valuewill be printed by printf() function. This will print value of a “10” on the screen.
·        To print multiple variable’s value one can use printf() function in following way.
Int p=1000,r=10,n=5;
Printf(“amount=%d rate=%d year=%d”,p,r,n);
This will print “amount=1000 rate=10 year=5” on the screen

Scanf() Function :
·        Scanf() function is use to read data from keyboard and to store that data in the variables. The general syntax for scanf() function is as follows.
Scanf(“Format String”,&variable);
·        Here format string is used to define which type of data it is taking as input this format string can be %c for character, %d  for integer variable and %f  for float variable.
·        Where as variable the name of memory location or name of the variable and & sign is an operator that tells the compiler the address of the variable where we want to store the value.
·        One can take multiple input of variable with single scanf() function but it is recommended that there should be one variable input with one scanf() function.

Single character input – the getchar( ) function :
·        Single characters can be entered into the computer using the “C” library function getchar. The getchar function is a part of the standard “C” language I/O library.
·        It returns a single character from a standard input device (typically a keyboard).
·        The function does not required any arguments through a pair of empty parentheses must follow the word getchar.
·        In general terms, a reference to the getchar function is written as.

Character variable=getchar();

·        Where character variable refers to some previously declared character variable.

Single character output – The putchar( ) function:

·        Single character can be displaye using the C library function putchar.
·        The putchar function, like getchar is a part of the standard “C” language I/O library.
·        It transmits a single character to a standard output device.
·        The character being transmitted will normally be represented as a character-type variable.
·        It must be expressed as an  argument to the function, enclosed in parentheses following the word putchar.
·        In general a reference to the  putchar function is written as
Putchar (character variable)

Where character variable refers to some previously declared character


getc() Function

The C library function int getc(FILE *stream) gets the next character (an unsigned char) from the specified stream and advances the position indicator for the stream.
Following is the declaration for getc() function.
int getc(FILE *stream)
stream is the pointer to a FILE object that identifies the stream on which the operation is to be performed. This function returns the character read as an unsigned char cast to an int or EOF on end of file or error.

putc () Function :

The C library function int putc(int char, FILE *stream) writes a character (an unsigned char) specified by the argument char to the specified stream and advances the position indicator for the stream.
Following is the declaration for putc() function.
int putc(int char, FILE *stream)
char  is the character to be written. The character is passed as its int promotion. stream  is the pointer to a FILE object that identifies the stream where the character is to be written. This function returns the character written as an unsigned char cast to an int or EOF on error.

gets() Function

The C library function char *gets(char *str) reads a line from stdin and stores it into the string pointed to by str. It stops when either the newline character is read or when the end-of-file is reached, whichever comes first.
Following is the declaration for gets() function.
char *gets(char *str)
str  is the pointer to an array of chars where the C string is stored. This function returns str on success, and NULL on error or when end of file occurs, while no characters have been read.

puts() Function

The C library function int puts(const char *str) writes a string to stdout up to but not including the null character. A newline character is appended to the output.
Following is the declaration for puts() function.
int puts(const char *str)
str  is the C string to be written. If successful, non-negative value is returned. On error, the function returns EOF.

 

getchar () Function
The C library function int getchar(void) gets a character (an unsigned char) from stdin. This is equivalent to getc with stdin as its argument.
Following is the declaration for getchar() function.
int getchar(void)
This function returns the character read as an unsigned char cast to an int or EOF on end of file or error. The int getchar(void) function reads the next available character from the screen and returns it as an integer. This function reads only single character at a time. You can use this method in the loop in case you want to read more than one character from the screen.

 

putchar () function
The C library function int putchar(int char) writes a character (an unsigned char) specified by the argument char to stdout.
Following is the declaration for putchar() function.
int putchar(int char)
char  is the character to be written. This is passed as its int promotion.
This function returns the character written as an unsigned char cast to an int or EOF on error. The int putchar(int c) function puts the passed character on the screen and returns the same character. This function puts only single character at a time. You can use this method in the loop in case you want to display more than one character on the screen. Check the following example −

Ungetc() function

The C library function int ungetc(int char, FILE *stream) pushes the character char (an unsigned char) onto the specified stream so that the this is available for the next read operation.
Following is the declaration for ungetc() function.
int ungetc(int char, FILE *stream)
char  is the character to be put back. This is passed as its int promotion. stream  is the pointer to a FILE object that identifies an input stream. If successful, it returns the character that was pushed back otherwise, EOF is returned and the stream remains unchanged.


Wednesday, October 19, 2016

Oracle One Mark Question for BCA, BSc(IT) and P.G.D.C.A.



Prepared By : Uday Shah - HOD(IT)
Contact No : 7600044051

---------------------------------------------------------------------------------

1.       '> ALL' means –
same as the IN operator
2.       The main purpose of creating a view is for –
data definition 
3.       The 'WITH CHECK OPTION' clause of the view is used to-
restrict access rights
4.       Which two statements are true for the ORDER BY clause?
The default is ascending order
5.       Which of the following are true for creating synonyms?
There are many columns in a table      
6.       The Top-N Analysis requires-
GROUP BY clause, an inline view
7.       What is true about updating a view?
When a view is updated the group functions are automatically updated
8.       If group functions are used on columns containing NULL values then-
The NULL values are converted to appropriate data types
9.       Which privileges can be grant on a view?
ALTER, SELECT, INDEX
10.     If a user has a CREATE VIEW privilege, it means he/she can-
create a view in any schema         
11.     The ROWID is a-
A binary data of 8 megabytes or  hexadecimal string
12.     The ROWNUM is a-
An octal number
13.     Which statement does not end a transaction-
GRANT
14.     Which two statements end a transaction –
DROP
15.     Identify the correct command to create a new user-
CREATE USER newuser IDENTIFIED BY newuser00
16.     An index is most useful when.
The indexed column does not contain a wide range of values
17.     An Index is automatically created on.
the first column
18.     An index uses the.
          rownum
19.     When 'WITH GRANT OPTION' is used in the GRANT command.
It allows the grantee to grant object privileges to other users
20.     The main purpose of creating a ROLE is.
To have a table that can be accessed by all   
21.     _____________ is an Organized collection of Data.
          a) DBMS
22.     The Relational Model  of database was introduced by
Dr. E.F.Codd     
23.     In Database, a row is also known as
Tuple        
24.     In entity relationship model, what are the types of relationship?
One – to – One   ,  One – to – many  ,  Many – to One      
25.     Relational Concept was introduced in the year of 
          1977
26.     Which is one of the Admin account in Oracle.
System      
27.     The Last Buffered command can be executed using
           RUN          and   /                           
28.     Which is  the SQL declaration category.
          DDL ,   DCL , DML             
29.     Viewing data from the user’s created table, which command can be used.
           Select        Command
30.     Converts a character value to a member using the format provided.
To_Number()    
31.     ______ clause can restrict groups.
          Having
32.     In Oracle Date Data type can store.
          Month        ,  Hour ,  Minute         
33.     You can share your own object locally with the help of
          Grant                 
34.     In Outer left and right join, _______ Operator can be userd.
          + ( Plus)


35.     Which one is the TCL Statement.
          Commit ,  Savepoint
36.     Which is  the set operator in Oracle.
          Union , Union All , Minus , Intersect             
37.     View is a.
          Logical Table
38.     A ________ is based on a single table and does not contain function or grouped data.
          Simple View      
39.     Which  parameter of the sequence object can not be altered.
          Start with 
40.     Lock Types are
          DML Locks        ,  DDL Locks      , Latches 
41.     The Full form of PL/SQL block is.
          Procedural Language
42.     The Data type that is not supported by oracle table but PL/SQL is.
          Boolean
43.     To know the status of Cursor, we  use
          Cursor Attributes
44.     To avoid any  data type mismatches in PL/SQL we can use.
%type       
45.     Cursor attribute are prefixed with the cursor name  
in
Explicit Cursor
46.     The default parameter mode is
          IN Mode   
47.     Exception can be raised using
          Raise_Application_Error
48.     _____ is name PL/SQL module that can perform one or more task and does not contain any return value.
          Function
49.     Instead of Trigger is based on VIEW instead of a database table.
          True
50.     Which type of file is part of the Oracle Database.
          Control File       
51.     Transaction per roll back segment is derived from.
          Processes
52.     _____ file reside on the client.
          TNSNAMES.ORA
53.     ____ Media recovery is used to recover from a lost or damaged current data file or control file.
Datafile
54.     When Database is running 24 * 7 basis , the backup should be
          Online Backup
55.     In Relational Database Terminology, Columns is called _________
          Attribute


56.     E – R Diagram  is one of the Model that was Developed By ________ in 1976.
          P.P.Chen  
57.     When the tables are formed with primary keys, the DBMS is in
          1NF 
58.     Date must be inserted according to oracle format only that is, __________
          DD/MON/YY
59.     Which operator return TRUE result if one of the two condition is TRUE?
AND
60.     SQL is Case – Insensitive.
TRUE
61.     RDBMS Tools are
DBMS  , RDBMS , MS SQL Server
62.     Online Backup is also called.
          Hot  
63.     NET8 Interface is for
          Both Client and Server       
64.     The Session Information is stored in
PGA
65.     Which has same Size?
Data Block         
66.     Cursor is a _____ workarea.
          Temporary
67.     The __________ can be used to initialize a constant  or a variable to a value.
:=
68.     ____________ is a pre – test loop
          While
69.     _____ Provide auto increment and auto declaration of Variable.
For Loop
70.     When the variable is not initialized in PL/SQL block, it contains __________ value.
          a)  NULL  
71.     Two Copies of the same table is created in memory if the join is.
          Self Join
72.     _______ Marks and saves the current point in the processing of a transaction.
Savepoint
73.     _________ return current data and time.
SYSDATE ()
74.     The Symbol of concatenation operation in oracle is
| |
75.     Which category can be used for Table Structure only.
DDL
76.     To compare Single Character with Like Operator
_  (Dash)
77.     Which satisfy all 12 rules for ideal RDBMS.
None
78.     The Query is Process By
Server
79.     Lock Types are ..
All
80.     The ____ Loop does not need an EXIT statement to terminate.
While
81.     A primary key is always
Unique and not null
82.     A foreign key can refer to a
Only primary key of another table
83.     The constraint, which can be defined only at column level, is
Not null
84.     A foreign key can be specified with the table name only when
Both columns have same datatype and column width
85.     Which of the following is not a character data type?
BLOB
86.     Entity Integrity rule refers to the
Primary key
87.     Referential Integrity rule refers to the
Foreign key
88.     A single check constraint can refer to more than one column at
Table level only
89.     'On delete cascade' is used to
Delete parent records and corresponding child records
90.     A unique index is created for which two constrains from the following
Primary key  , Unique Constraint
91.     When you create a table, which of the following holds true?
It is created in the DBA schema
92.    When the DBA creates a user using the command – CREATE USER username IDENTIFIED BY  password, which privileges dose have at this point?
No privilege
93.     Maximum size of  naming a table?
Maximum size is 30 characters
94.     Which of the following modifications are not allowed once the table is created but is not empty?
Decreasing the size of column
95.     The RENAME command can't be used to change the name of
A column
96.     The NUMBER data type can't be used for
Hexadecimal
97.     The DATE data type stores
          MON/DD/YY


Wednesday, October 12, 2016

C Language Date and Time Library Function For BCA , BSc(IT) , PGDCA and Other IT Students



Prepared By : Uday Shah - HOD (IT)
Contact No : 7600044051
--------------------------------------------------------------------------------------------------------------------------

String Library Function

Clock
Returns number of clock ticks since program start
Declaration: 
clock_t clock(void);
 Remarks:
clock can be used to determine the time interval between two events.
To determine the time in seconds, divide the value returned by clock by the
value of the macro CLK_TCK.


Difftime
Computes difference between 2 times
 Declaration: 
double difftime(time_t time2, time_t time1);
 Remarks:
difftime calculates the elapsed time in seconds, from time1 to time2.
 Return Value:
Returns the result of its calculation, as a double.



Mktime
Converts time to calendar format
Declaration: 
time_t mktime(struct tm *t);
 Remarks:
Converts the time in the structure *t into a calendar time with the same format used by the time function. The original values of the fields tm_sec, tm_min, tm_hour, tm_mday, and tm_mon are not restricted to the ranges described in the tm structure.

If the fields are not in their proper ranges, mktime adjusts them. mktime computes values for the fields tm_wday and tm_yday after the other fields have been adjusted.


Time  & Stime

time gets time of day
stime sets system date and time
 Declaration:
          time_t time(time_t *timer);
          int stime(time_t *tp);
 Remarks:
time gives the current time, in seconds, elapsed since 00:00:00 GMT, January 1, 1970. It stores that value in the location *timer, provided that timer is not a null pointer.

stime sets the system time and date, measured in seconds from 00:00:00 GMT, January 1, 1970. tp points to the value of the time.


Asctime & Ctime
asctime converts date and time to ASCII
ctime converts date and time to a string
 Declaration:
char *asctime(const struct tm *tblock);
char *ctime(const time_t *time);
Remarks:
asctime converts a time stored as a structure in *tblock to a 26 character string.

ctime converts the time value *time into a 26-character string.


Gmtime &  Localtime
gmtime converts date and time to Greenwich Mean Time (GMT)
localtime converts date and time to a structure
 Declaration:
struct tm *gmtime(const time_t *timer);
struct tm *localtime(const time_t *timer);
 Remarks:
Both functions accept the address of a value returned by time and return a pointer to a tm structure containing the broken-down time.
gmtime converts directly to GMT; localtime corrects for the time zone and possible daylight saving time.


Strftime
Formats time for output
 Declaration:
size_t _cdecl strftime(char *s, size_t maxsize, const char *fmt,
                                                const struct tm *t);
Remarks:
strftime formats the time in *t into the array *s according to the format specifications (a format string) in *fmt.
Return Value:
On success, strftime returns the number of characters placed into s.

On error (if the number of characters required > maxsize), returns 0.

C Language String Library Function For BCA , BSc(IT) , PGDCA and Other IT Students



Prepared By : Uday Shah - HOD(IT)
Contact No : 7600044051
--------------------------------------------------------------------------------------------------------------------------

String Library Function

Strcpy
Copies all most haracters of src to dest

Declaration:
     char *strcpy(char *dest, const char *src);

Remarks:
     Copies string src to dest, stopping after the terminating null character has been moved.


strncpy
Copies at most maxlen characters of src to dest

Declaration:
     char *strncpy(char *dest, const char *src, size_t maxlen);
    
Remarks:
     strncpy copies up to maxlen characters from src into dest,      truncating or null-padding dest. _fstrncpy is the far version.

     The target string, dest, might not be null-terminated if the length of src
     is maxlen or more.


strcat
Appends one string to another

Declaration:
char *strncat(char *dest, const char *src, size_t maxlen);

Remarks:
     strncat copies at most maxlen characters of src to the end of dest and      then appends a null character.


strchr
Scans a string for the first occurence of a given character

Declaration:
char *strchr(const char *s, int c);

Remarks:
strchr scans a string in the forward direction, looking for a specific character.

strrchr
Finds the last occurrence of c in s

Declaration:
char *strrchr(const char *s, int c);

Remarks:
strrchr scans a string in the reverse direction, looking for a specific character.

strcmp
strcmp compare two strings
int strcmp(const char *s1, const char*s2);

Remarks:
The string comparison starts with the first character in each string and continues with subsequent characters until the corresponding characters differ or until the end of the strings is reached.

To use strcmp, you must include STRING.H. This macro is provided for compatibility with other C compilers.

strncmp
strncmp compare portions of two strings. strncmpi is a macro compares portions of two strings, without case sensitivity

Declaration:
int strncmp (const char *s1, const char *s2, size_t maxlen);


Remarks:
Each of these routines compares s1 to s2, looking at no more than maxlen characters.


The string comparison starts with the first character in each string and continues with subsequent characters until the corresponding characters differ or until maxlen characters have been examined.

To use strncmp, you must include STRING.H.




strcspn
strcspn scan a string for a segment that DOES NOT contain a subset of a set of characters .strspn scan a string for a segment that IS a subset of a set of characters

Declaration:
size_t strcspn(const char *s1, const char *s2);

Remarks:

strcspn find the initial segment of string s1 that consists entirely of characters NOT from string s2.

Strlen
Calculates length of a string

Declaration:
size_t strlen(const char *s);
    
Remarks:
strlen calculates the length of s.

Return Value:
Returns the number of characters in s, not counting the terminating null




strpbrk
Scans one string for the first occurrence of any character that is in a second string

Declaration:
char *strpbrk(const char *s1, const char *s2);

Remarks:
strpbrk scans a string, s1, for the first occurrence of any character appearing in s2.


Please Give Your Comment  and Share it......