C Interview Questions: Q1) - What Is C Programming Language?
C Interview Questions: Q1) - What Is C Programming Language?
C Interview Questions: Q1) - What Is C Programming Language?
Variables
A variables is a value or an identifier whose value can be
changed in a program. Variable is a container to hold
data.
For example:
int score = 6;
Here, score is a variable of integer type and it contains
value 6. The value of score can be change so here score
is variable.
}
Output:
puts() printf()
1. The printf() function
1. The puts() function only can print strings as well as
allows you to print a string on mixed types of variables
the console output screen. on the console output
screen.
2.The syntax for puts: 2.The syntax for printf:
puts(str) printf(str)
3. The puts() function prints
3.The printf() function
string and automatically adds
prints text, string, text+
one new character at the end
value, etc, without adding
of the string that is a new line
extra character at the end.
character(\n).
4. Its implementation is
4. Its implementation is
complex as compared to
simpler than printf.
puts.
continue :
The continue statement is used to skips some statements
inside the loop. The continue statement is used with
decision making statement such as if…else.
# include <stdio.h>
int main()
{
int i,n, sum = 0;
for(i=1; i <= 5; ++i)
{
printf("Enter a n%d: ",i);
scanf("%d",&n);
if(n < 5)
{
continue;
}
sum += n;
}
printf("Sum = %d",sum);
return 0;
}
Output:
#include<stdio.h>
void hello(){
printf("hello c programming \n");
}
int main(){
hello();
return 0;
}
Output:
}
Output:
Output:
} emp;
int main()
{
strcpy(emp.name, "Prakash");
emp.salary = 28000;
Output:
Class name
Modifiers
Interface
Super Class
Methods
Members
Constructor
Blocks
Nested Class
Nested Interface
Declaration of Class
class {
field;
method;
}
Public
Private
Protected
Default
Method overloading
Method Overriding
view raw
Interface program example in java.java hosted with
by GitHub
Output
4
Example of StringBuffer:
StringBuffer strbfr=new StringBuffer("prakash");
strbfr.append("kumar");
System.out.println(strbfr);
output:- prakash kumar
Set
List
Queue
Dequeue
ArrayList
LinkedList
HashSet
TreeSet
LinkedHashSet etc.
import java.util.*;
public class Animal{
public static void main (String [ ] args){
Linkedlist <String>names=new Linkedlist <String>();
names.add ("Dog");
names.add ("Cat");
names.add ("Donkey");
names.add ("Cow");
System.out.println (names);
}
}
Output:
[Dog, Cat, Donkey, Cow]
3). Vector
Similar as ArrayList.
Maintain the Insertion Order.
It can have duplicate values.
Its Methods are Synchronized.
import java.util.*;
public class Animal{
public static void main (String [ ] args){
Vector <String>names=new Vector <String>();
names.add ("Dog");
names.add ("Cat");
names.add ("Donkey");
names.add ("Cow");
System.out.println (names);
}
}
Output:
[Dog, Cat, Donkey, Cow]
Example:
import java.util.*;
public class Animal{
public static void main (String [ ] args){
HashSet <String>names=new HashSet <String>();
names.add ("Dog");
names.add ("Cat");
names.add ("Donkey");
names.add ("Cow");
names.add ("Dog");
System.out.println (names);
}
}
Output:
[Dog, Cat, Donkey, Cow]
import java.util.*;
public class Animal{
public static void main (String [ ] args){
LinkedHashSet <String>names=new LinkedHashSet
<String>();
names.add ("Dog");
names.add ("Cat");
names.add ("Donkey");
names.add ("Cow");
names.add ("Dog");
System.out.println (names);
}
}
Output:
[Dog, Cat, Donkey, Cow]
import java.util.*;
public class Animal{
public static void main (String [ ] args){
TreeSet <String>names=new TreeSet <String>();
names.add ("Dog");
names.add ("Cat");
names.add ("Donkey");
names.add ("Cow");
names.add ("Dog");
System.out.println (names);
}
}
Output:
[Dog, Cat, Donkey, Cow]
addition (+)
subtraction (-)
multiplication (*)
division (/)
remainder/modulus (%)
equal to (=)
not equal to (!= or <>)
less than (<),
greater than (>)
less than or equal to (<=)
greater than or equal to (>=)
not less than (!<)
not greater than (!>)
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
OFFSET
FETCH FIRST
UNION
INTERSECT
EXCEPT
WITH
Q20). What is SET Operators ? Explain UNION, UNION
ALL, Minus and Intersect commands?
Ans:
UNION : UNION Command is used to combine the result
of two select queries and make it one. To Perform the
UNION Operation, Select query should have similar field
and also the data type of the all field should be similar.
Here Duplicate rows will be eliminated
Syntax:
SELECT (coloumn) from table1 [WHERE condition]
UNION SELECT (coloumn) from table2 [WHERE
condition];
UNION ALL: UNION ALL is similar to UNION the only
difference is, UNION ALL can’t eliminate the duplicate
value.
Syntax:
SELECT (coloumn) from table1 [WHERE condition]
UNION ALL SELECT (coloumn) from table2 [WHERE
condition];
MINUS : MINUS Command returns the result only from
the first select query which is not available in second
select query. In MINUS Operation, Select query should
have similar field and also the data type of the all field
should be similar.
SELECT (coloumn) from table1 [WHERE condition]
MINUS SELECT (coloumn) from table2 [WHERE
condition];
INTERSECT : INTERSECT Command is used to return
only common data as a result from two select queries.
Intersection operation always returns the distinct rows.
SELECT (coloumn) from table1[WHERE condition]
INTERSECT SELECT (coloumn) from table2 [WHERE
condition];
Q21). What is Cursor in SQL?
Ans:
A Cursor in SQL is a Temporary Memory or temporary
work area which is used when a DML operation is
performed on the table.
There are two types of Cursor
1. Implicit Cursor
2. Explicit Cursor
Trigger Syntax
Simple View
Complex View
Inline View
Materialized View
Count()
Sum()
Avg()
Min()
Max()
FIRST()
LAST()