Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 40

Q1. what is the purpose of the programming?

Ans-->if we want to communicate a computer then we should go for programming language.

Q2. what is the flow of the program?


Q2. Explain types of programming language?

Ans-->Basically there are 3 types of programming language

1. Low Level Language

All instruction written inform of 0 and 1.

Execution of low level language is fast as compare to all types of programming language

Example: Binary Language/ Assembly Language

2. Middle Level

it support some features of low level language and high level language

This is very easy as compare to low level language

This is fast as compare to high level language

This is slow as compare to low level language.

Example: C C++

3. high level

User friendly programming language

This is slow as compare to low level and middle level programming language
High level language does not interact hardware directly. it can interact with other component like JVM
in java, PVM in python

Example: Java, python

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

Q3. Explain Procedural Oriented programming language?

Ans-->A procedural language is a computer programming language that follows in order, a set
commands Example of procedural programming language are

C, FORTRAN, Pascal, BASIC,COBOL

Procedural language are some of the common types of programming language used by script and
software programming variables, data type, conditional statement, function to create programs that
allows a computer to calculate and display output.

Q4. Explain Object oriented programming?

Ans-->Object Oriented programming(OOP) is a programming paradigm that relies on the concept of


classes and object. it is used to structure a software program into simple, reusable piece of code
blueprint. There are many object oriented programming

like C++,Java, Python

Simula is a first object oriented programming language

Q5. Explain types of software ?

Ans-->There are 2 types of software

1. System Software(OS)

2. Application Software()
1.System Software: System software controls a computer internal functioning through an operating
system and also control monitors, printers and storage devices.

Example: Operating System

2. Application Software: An applications is any program, or group of programs that is designed for the
end user. Application software also called End-user software

Example: MS office, oracle, MySql

Q2. Explain History of C Programming?

The root of All modern language is ALGOL introduced in 1960

Algol uses a structure programming

After Algol 1967 new languages developed by Martin Richards BCPL(Basic Combined programming
language)

Primarily BCPL is developed for system software

in 1970 , Ken Thomson created a language called B language

B is created for UNIX OS at Bell laboratories

Both BCPL and B language are type less

in 1972 Mr. Dennis Richie created a new language is call C language

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

Q3. What is the structure of program

Ans-->

1. Documentation section

//Single Line Comment

/*

Multiple Line Comment

*/

It is used to increase Readability of the program

Compiler always ignore comment statement


2. Include section

if we are use any pre-defined function in our program then we include below header file

#include<stdio.h>

#include<conio.h>

output function

printf()

puts()

putchar()

input function

scanf()

gets()

getchar();

Screen clear and screen hold (only in Turboo C++)

clrscr();

getch();

3. User Defined Function Section

//Global Function

//Function Declare

// Function Definition

//Structure, union, enum

//class
4. void main(){

//local variable

clrscr();

//Executable code

getch();

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

1. documentation section

2. Include Section

3. User Defined Section

4. void main()

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

Q3. which software is required to compile and execute C program?

Ans--> There are many software available for c / C++ programming

1. Turbo C++

2. Dev C++

3. Code Block

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

Q4. write a c Program to say Hello world on the screen

Hello World
// This is My First Program using c

#include<stdio.h>

void main(){

printf("Hello World");

Q2. Explain Keywords in C Programming?

Ans-->Keywords are reserved words that have a special meaning to c compiler

auto

break

case

char

continue

default

do

int

float

double

else

if

while

goto
for

sizeof

long

struct

switch

enum

union

return

typedef

void

signed

unsigned

1. Keywords always written lowercase

2. space

3. Identifier name should not be keyword.


Q1. Explain what is Identifier in c programming?

Ans-->identifier is a name given by the programmer it may be name of variable, name of function, name
of array, name of pointer, name of structure, name of class, name of object

int num;

1. Identifier name can be combination of alphabet and digits. but always starts with an alphabet

for example

int 123num;//invalid

int num123;//valid

int num@123;//invalid

int 45;//invalid

int abc; //valid

2. in c programming language only one special character allowed that is


underscore(_). In C Programming underscore (_) is also count as an alphabet.

int num 123;//invalid

int num-123;//invalid

int num_123;//valid

int _123;//valid

3. Identifier name should not be keywords.

int FOR;//valid

int for;//invalid
Q3. Explain static typed programming language and dynamic typed programming
language?

Ans-->

static typed Programming language: statically typed language can be referred to


the language where the type of variable is known at compile time

data type variable name;

int a, b, c;

a=10;

b=20;

c=a+b;

Example: C, C++, Java is a static typed programming language

Dynamic Typed programming language: dynamically typed language can be


referred to the language where the type of variable is known at run time

a=10;

b=20;

c=a+b;

Example: Python is a dynamically typed programming language.


Q3. Explain Data type in c Programming?

Ans-->Data type can specify what type data can be occur and how many bytes
memory could be allocated

mostly 4 data type used in any programming

1. int

2. float

3. double

4. char

1. int: if we want to store fixed number whole number then we should go for int
data type

Example: age, rollno, sno,

Note: if both operand are int result always will be int

9/2=4

Size in memory

16-bit complier

int 2 byte

32-bit compiler

int 4 byte

Range:

16-bit compiler
-32768 To +32767

32-bit compiler

-2,147,483,648 To +2,147,483,647

format Specifier

int %d or %i

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

2. float : if we want to store real number upto 7 decimal places then we should go
for float data type

Example: per, avg, strike rate

size in memory

float 4 byte

format Specifier

float %f

if one operand is int and another operand is float

float x=9.0/2;

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

3. double : if we want to store real number upto 16 decimal places then we


should go for double data type

Example: amount

size in memory

double 8 byte
format Specifier

double %lf

if one operand is int and another operand is double

double x=9.0/2;

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

4. char : if we want to store single alphabet then we should go for char data

char constant always written within single quote

'1'---------->char

'A'--------->char

size in memory

char 1 byte

format Specifier

char %c

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

Q3. Explain Variable in C Programming?

Ans--> Variable is a temporary memory location it is used to store a value

value of variable may be change during execution of the variable

one variable can store only one value at a time


Q2. How to declare and initialize variable in c programming?

Ans-->variable declaration is nothing but to inform its properties to compiler.

Properties:

Data Type variable name;

int num;

Properties:

Data type: int

size in memory: 4 byte

How to initialize a variable:

initialization of the variable is nothing but assigning value to the variable

variable name=value
num=25;

if we want to print value of any variable then we should go for printf() function

printf("for mat Specifier ",variable name);

printf("Value of num %d ",num);

Q1. write a c program to print sum of two numbers

Addition: 30
------------------------------------------------------------------------------------------------------------

Q2. write a c program to calculate area and circumference of circle

Area of Circle

Circumference
------------------------------------------------------------------------------------------------------------

Q3. write a c program to print grade employee


Q3. Explain puts function in c programming?

Ans--> if we want to display only string or multiple character on the screen then
we should go for puts

Q4. write a c program to print your introduction on the screen without using
printf()

Hello I am ram

i am from bhopal

I work for T&P


Q3.Explain putchar function in c programming?

Ans-->if we want to print char by char on the screen then we should go for
putchar function

it is only for char data type not for other.

Q4. write a c program to print LNCT on the screen without using printf() and
puts()

LNCT
Q5. Explain scanf function in c programming?

Ans-->if we want to take input (any type) form the user then we should go for
scanf function

In c Programming, scanf() is one commonly used function to take input from the
user. The scanf function reads formatted input from the input device keyboard

scanf("format Specifier", &variable name);

Q6. Write a c program to calculate area and parameter of the rectangle

Enter Length : 4

Enter Breadth :5

Area Of Rectangle : 20

Parameter of Rectangle: 18
Q2. write a c program to take input radius from the user and calculate area and
circumference of the circle.

Enter Radius: 3.5

Area:

Circumference:
Q2. write a c program to take grade of employee from the user and print it on the
user

Enter Grade of Employee: A

Grade OF Employee: A
Q1. Explain Operator in c programming?

Ans-->An Operator is a symbol that operates on a value or a variable.

in below example

10+20

in above expression 10 and 20 is an operand and + is an operator

int a,b,c;

a=10;

b=20;

c=a+b;

in above expression a,b,c are operand and +,= is an operator

on the basis of number of operand there 3 types of operators in C programming


1. Binary Operator: it takes two operand at a time and perform some specific
operations

Example: +,-,*,/,%

2. Unary Operator: It takes one operand at a time and perform some specific
operation

Example: i++,i--,sizeof(),~,!

3. Ternary Operator: It takes three operand at a time and perform some specific
operation

Example: Conditional Operator

10>20?10:20;

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

Q2. Explain on the basis of functionality how many types of operators available in
c programming

Ans-->There are 8 types of operator available in c programming

1. Arithmetic Operator[+,-,*,/,%,++,--]

2. Relational Operator [>,<,>=,<=,==,!=]

3. Logical operator [&&,||,!]

4. Bitwise Operator[&,|,~,<<,>>,^]

5. sizeof

6. Conditional operator / Ternary Operator [?:]

7. Assignment Operator[=,+=,-=,*=,/=]
8. Comma operator(,)

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

Q1. Explain modulo (%) operator in c programming?

Ans-->if we want to find reminder of any number(int) then we should go for


modulo operator in c programming

in c programming modulo operator only work with int data type

Syntax:

First Operand % second Operand=Reminder

23%5------------>3

10%4------->2

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

First Operand / second Operand--->quotient

23/5======>4

10/4------>2
Q1. write a c program to find reminder of any number.

Q2.Explain increment(++) and decrement(--) operator in c programming?

Ans-->if we want to increase or decrease value of variable by 1 then we should go


for increment (++) and decrement (--) operator in c programming

by ++ and -- value of variable always increase or decrease by 1.


Q3. Explain pre-increment and post increment operator in c programming?

Ans-->

pre-increment: A-pre increment operator is used to increment the value of a


variable before using it in a expression. In the pre-increment , value is first
incremented and then used inside the expression

pre-decrement: A-pre decrement operator is used to decrement the value of a


variable before using it in a expression. In the pre-decrement , value is first
decremented and then used inside the expression

//increment / decrement operator

#include<stdio.h>

void main(){

int a,b,c,d;

a=5;
b=10;

c=++a;// a=a+1--->a=5+1=6 c=6, a=6 pre -increment

d=--b; //pre-increment

printf("\n Value OF A %d ",a);

printf("\n Value of C %d ",c);

printf("\n Value d %d ",d);

printf("\n Value b %d ",b);

Q4. Explain post-increment and post decrement in c programming?

Ans-->

Post Increment : A post increment operator is used to increment the value of a


variable after executing expression completely in which post increment is used. in
the post increment, value is first used in a expression and then incremented.

Post decrement : A post decrement operator is used to decrement the value of a


variable after executing expression completely in which post decrement is used.
in the post decrement, value is first used in a expression and then decremented.
Q6. Explain relational operator in c programming?

Ans-->if we want to compare something then we should go for relational operator

we discuss following relational operator

>

<

>=

<=

==

!=

result of all relational operator is true(1) or false(0)


Q6. Explain logical operator in c programming?

Ans--> if we want to combine more than one conditions then we should go for
logical operator

we discuss following logical operator

1. logical and (&&)

2. Logical or (||)

3. Logical not (!)

result of all logical operators is true(1) or false(0).

Q7. Explain Logical && operator in c programming?

Ans-->Result of logical and (&&) operator is true(1) when all conditions under
consideration are true(1).
Result of logical and (&&) operator is false(0) when one or all conditions under
consideration are false(0).

logical and(&&)

A B A&&B
1 0 0
0 1 0
0 0 0
1 1 1
Q8. Explain Logical || operator in c programming?

Ans-->Result of logical OR (||) operator is true(1) when one or more than one
conditions under consideration are true(1)

Result of logical OR (||) operator is false(0) when all conditions under


considerations are false(1)

logical OR(||)

A B A||B
1 0 1
0 1 1
0 0 0
1 1 1
Q3. Explain logical not(!) operator in c programming?

Ans-->it is used to check the opposite result of any given test conditions. if any
condition result is non-zero(true) it returns 0 that is false.

if any conditions result is false(0) it returns true(1).

A !A
1 0
0 1
Q1. Explain bitwise operators in c programming?

Ann-->if we want to perform bit by bit manipulation then we should go for


bitwise operators in c programming

we discuss following bitwise operators

1.Bitwise AND (&)

2. Bitwise OR (|)

3. Bitwise NOT (~)

4. Bitwise Left Shift Operator[<<]

5.Bitwise Right Shift Operator[>>]

6. XOR Operator [^]


Decimal Number Binary Number
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001

Q1. Explain bitwise and(&) Operator in C programming?

Ans-->Result of bitwise AND & operator is 1 when both bits are 1.

Result of bitwise AND operator is 0 when one or both bits are 0.

Bitwise & Operator

A B A&B
1 0 0
0 1 0
0 0 0
1 1 1

Example:

5----> 0 1 0 1
6----> 0 1 1 0
5&6--->4 0 1 0 0
Q2. Explain bitwise OR(|) Operator in C programming?
Ans-->Result of bitwise or (|) operator is 1 when one or both bits are 1.

Result of bitwise OR (1) operator is 0 when both bits are 0.

Bitwise | Operator

A B A|B
1 0 1
0 1 1
0 0 0
1 1 1

Example:

5----> 0 1 0 1
6----> 0 1 1 0
5|6--->7 0 1 1 1
Q3. Explain bitwise not (~) operator in c programming?

Ans-->

Result of bitwise not (~) operator is 1 when bits is 0.

Result of bitwise not(~) operator is 0 when bit is 1.

It takes only 1 bit at a time hence this is unary operator

bitwise not Operator(~)

A ~A
1 0
0 1
Example:

4----> 0100---------->0000 0100

128 64 32 16 8 4 2 1
0 0 0 0 0 1 0 0
1 1 1 1 1 0 1 1

First bit of number is signed bit

1 means negative

0 means positive

You might also like