0% found this document useful (0 votes)
35 views32 pages

C Function for Unary Quadratic Equation

This document discusses the fundamentals of C programming including what C is, its features, common uses, the structure of a C program, tokens including keywords and data types, constants, and operators. It provides examples to illustrate various concepts.

Uploaded by

Arya Vinod
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views32 pages

C Function for Unary Quadratic Equation

This document discusses the fundamentals of C programming including what C is, its features, common uses, the structure of a C program, tokens including keywords and data types, constants, and operators. It provides examples to illustrate various concepts.

Uploaded by

Arya Vinod
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

C- Programming Fundamentals of C-programming

Chapter-2. Fundamentals of C-programming


What is C?
C is programming language used to write program and execute them.
C is a procedural programming language. It was initially developed by Dennis Ritchie in the year
1972.
It is a low programming level language close to machine language.
It is widely used in the software development field.

Features of C?
1) It is a procedural language
2) It is high level language
3) It is used for software development.
4) ‘C’ language is a first step for programmer to start
5) It is reliable, simple, & easy to use.

Where is C used? Key Applications

1. 'C' language is widely used in embedded systems.


2. It is used for developing system applications.
3. It is widely used for developing desktop applications.
4. Most of the applications by Adobe are developed using 'C' programming language.
5. It is used for developing browsers and their extensions. Google's Chromium is built using 'C'
programming language.
6. It is used to develop databases. MySQL is the most popular database software which is built
using 'C'.
7. It is used in developing an operating system. Operating systems such as Apple's OS X,
Microsoft's Windows, and Symbian are developed using 'C' language. It is used for developing
desktop as well as mobile phone's operating system.
8. It is used for compiler production.
9. It is widely used in IOT applications.

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-1
C- Programming Fundamentals of C-programming

Structure of c program

A ‘C program’ basically consists of the following parts −

• Preprocessor Commands
• Functions
• Variables
• Statements & Expressions
• Comments

#include <stdio.h>
void main()
{
/*my first program in C */
printf("Hello, World! \n");
return 0;
}

▪ /* Comments */
This is a comment block, which is ignored by the compiler. Comment can be used anywhere in
the program to add info about the program or code block, which will be helpful for developers to
understand the existing code in the future easily.

▪ #include<stdio.h>
This is a preprocessor command. That notifies the compiler to include the header file stdio.h
in the program before compiling the source-code.

▪ int/void main()
int/void is a return value, which will be explained in a while.
This is the main function, which is the default entry point for every C program and the void in
front of it indicates that it does not return a value.

▪ Braces
Curly braces which shows how much the main() function has its scope.

▪ printf()
This is another pre-defined function of C which is used to be displayed text string in the
screen.

▪ return 0
At the end of the main function returns value 0.

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-2
C- Programming Fundamentals of C-programming

TOKENS OF C
The C programs are made up of different things termed as tokens.

The different tokens of C are


o Character set
o Keywords
o Identifiers
o Constants and variables
o Data types
o Operators

• CHARACTER SET
Character Set Example

Alphabets (Upper case and lower A, B, C ……Z


case) a, b, c …….z

Digits (numbers) 0, 1, 2, 3. .. .. . .. 9

Special Symbol @, #, $, ^, &, *, +, _, /, <, >

• KEYWORDS
✓ There are some special words that have a predefined meaning for the C compiler known as
keywords.
✓ Keywords are a set of words which are reserved for the certain operations and hence are also
sometimes referred as reserved words.
✓ These words cannot be used as identifiers.
✓ There are 32 Keywords in C.
✓ The keywords used in C are as given below:

auto double Int struct


break else Long switch
case enum register typedef
char extern Return union
const float Short unsigned
continue for signed void
default goto Sizeof volatile
do if Static while

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-3
C- Programming Fundamentals of C-programming

• IDENTIFIERS
Identifiers are name given to different user defined things like variables, constants, functions,
array, structures, unions, etc.
some rules need to follow while making these identifiers.
These rules are stated below:
▪ A Variable name consists of any combination of alphabets, digits and underscores.
▪ It should not start with the digit; the first character of the variable name must either be alphabet or
underscore.
▪ Commas and blanks are not allowed in the variable name.
▪ Special symbols are not allowed except underscore.
▪ You cannot use Keywords (reserve words) as variable name.

• DATA TYPE
What type of data can a variable hold is called data type.
▪ The data type decides the type of data required for storing in the memory.
▪ The data types of C can be divided into two types: primary and secondary data types.

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-4
C- Programming Fundamentals of C-programming

• CONSTANTS
▪ Constants are values given to the identifiers that do not change throughout the execution of the
program.
▪ Constants can be defined either by writing the keyword const before the data type by using
#define.
▪ Constants are used to declare the values that remain constant, for e.g. value of pi.

Declaration
– const float PI=3.14;
– #define PI 3.14

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-5
C- Programming Fundamentals of C-programming

Program: WAP to find area and circumference of circle.


#include <stdio.h>
#include<conio.h>
void main ()
{
float area, r, circ;
const float pi=3.14;
printf ("Enter a radius of circle: ");
scanf ("%f", & r);
area = pi * r * r;
circ = 2 * pi * r;
printf ("Area of Circle is %f \n",area);
printf ("Circumference of circle is %f \n",circ);
return (0);
}

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-6
C- Programming Fundamentals of C-programming

• ESCAPE SEQUENCES
▪ Escape sequence is a character followed by a backslash (\).
▪ They are used specially to perform some operations like going to new line, providing a horizontal
tab, vertical tab etc.
The following is a list of escape sequences.
\n Newline
\t Horizontal Tab
\v Vertical Tab
\b Backspace
\r Carriage Return
\f From feed
\a Audible Alert (bell)
\\ Backslash
\? Question mark

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-7
C- Programming Fundamentals of C-programming

OPERATORS
▪ Operators are different symbols used to perform operations on operands.
▪ The operators are one of the tokens of C.
▪ There are different types of operators classified based on their functions
Unary Operators
o These are operators that require only one operand
• Unary minus (-):
o It changes the algebraic sign of the variable to which it is preceded.
o For e.g., if x = 3 and y = 6 then
y = −x;

will make the value of y as -3.


• Address of operator (&):
o This operator returns the address of the variable associated with it.
o For e.g., y = &x;
o The memory address allocated to variable x will be copied into variable y.
• Casting operator or type conversion:
o It is used to convert one data type to another data type.
o The casting operator is used for type conversion
o E.g. int x=4;
Float y=5.1

Then x=(int) y; // result in x will be stored as 5

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-8
C- Programming Fundamentals of C-programming

Program: Write a program to accept a float number and display the integer part
using type casting operator.

#include<stdio.h>
#include<conio.h>
void main()
{
int a;
float b;
clrscr();
printf(“enter float number:”);
scanf(“%f”.&b);
a = (int)b;
printf(“the integer part of the number is :%d”,a);
getch();
}

output:

enter float number: 3.14


the integer part of the number is: 3

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-9
C- Programming Fundamentals of C-programming

Program: Write a program to display average of 5 subject.

#include<stdio.h>
#include<conio.h>
int main()
{
int Marks1, Marks2, Marks3, Marks4, Marks5,Add;
float Avg;
printf("\nEnter marks for five subject::");
scanf("%d%d%d%d%d",&Marks1,&Marks2,&Marks3,&Marks
4, &Marks5);
Add = Marks1+Marks2+Marks3+Marks4+Marks5;
Avg = (float)(Add)/5;
printf("\nAvg is = %f", Avg);
getch();
return 0;
}

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-10
C- Programming Fundamentals of C-programming

• Increment operator (++):


o It increases the value of the variable by one and stores the result in the variable itself.
o For e.g., if x =4,
Then x++; \\ Will make the value of x equal to 5.
o Operator “++” can be place after operand “x++” (also called as post increment operator)
and before operand “++x” (also called as pre increment operator).
o In post increment: x=4;
Then y=x++; will make value of y=4 and x=5;
o In pre increment: x=4
Then y=++x; will make value of y=5 and x=5
• Decrement Operator (--):
o It decreases value of the variable by one and stores the result in the variable itself.
o For e.g., if x = 4,
o Then x --; \\ Will make the value of x equal to 3.
o Operator “--” can be place after operand “x--” (also called as post decrement operator) and
before operand “--x” (also called as pre decrement operator).
o In post decrement: x=4;
Then y=x--; will make value of y=4 and x=3;
o In pre decrement: x=4
Then y=--x; will make value of y=3 and x=3

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-11
C- Programming Fundamentals of C-programming

Program: Write the output of the following program.

#include<stdio.h>
#include<conio.h>
void main()
{
int x=4, y=9;
int z;
z=(x++) +(--y) +y;
Printf(“Value=%d\n”,z);
z=(--x) +x+(y--);
printf(“Value=%d\n”,z);
getch();
}

output:

Value = 20
Value = 16

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-12
C- Programming Fundamentals of C-programming

Program: Write the output of the following program.

#include<stdio.h>
#include<conio.h>
void main()
{
int x=10, y, z;
z=y=x;
y-=--x;
z-=x--;
x-=--x-x--;
printf(“x=%d y=%d z=%d”, x, y, z);
}

output:

x=6
y=1
z=1

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-13
C- Programming Fundamentals of C-programming

• Size of operator :
o This operator is used to know the size of variable required to store value in memory.
o Size of operator can also find size of a data type.

1. sizeof(int) will return value as 2.


2. char a;
sizeof(a); will return 1

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-14
C- Programming Fundamentals of C-programming

Binary Operators
o Operators that require two operands are called as binary operators.
• Arithmetic Operators:
o This are set of operators used to perform basic arithmetic operations like addition,
subtraction, multiplication and division.
o There are five operators in this set. They are:

+ to find the sum


- to find the difference
* to find the product
/ to find the quotient after division
% to find the remainder after division
Division ‘/’ operator is used to find quotient and MOD ‘%’ operator is used to find remainder
after division of two numbers.
• Bitwise operators:
o The operator which works on each bit of data is known as bitwise operator.
o They perform different operations on bits of a data like AND, OR, EXOR, NOT etc…
o The operators are listed below:

& to perform bitwise AND operation


| to perform bitwise OR operation
~ to perform bitwise NOT operation
^ to perform bitwise EXOR operation
<< to perform bitwise left shift operation
>> to perform bitwise right shift operation

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-15
C- Programming Fundamentals of C-programming

1. Bitwise AND operation (&)

5 & 3 =1
( 5 )10 = (0 1 0 1)2
( 3 )10 = (0 0 1 1)2
(0 0 0 1)2= (1)10
2. Bitwise OR operation (|)
12 | 9 =13

( 12 )10 = (1 1 0 0)2

( 9)10 = (1 0 0 1)2

(1 1 0 1)2 = (13)10
3. Bitwise EXOR operation (^)
8 ^ 10 =2

( 8 )10 = (1 0 0 0)2

(10)10 = (1 0 1 0)2

(0 0 1 0)2 = (2)10
4. Bitwise NOT operation (~)
~ 7 = -8

(7)10 = (0 1 1 1)2

(1 0 0 0)2 = (−8)10
5. Left shift operator: (<<)
This statement will shift binary digit to the left by 1 digit.

3<<2 = 12

( 3)10 = (0 0 0 0 0 0 1 1)2

After shifting left once = ( 0 0 0 0 0 1 1 0)2

After shifting left twice = ( 0 0 0 0 1 1 0 0)2 =( 12)10

6. Right shift operator: (>>)


This statement will shift binary digit to the right by 1 digit.

13>>3 = 1

(13)10 = (0 0 0 0 1 0 1 1)2

After shifting right once = ( 0 0 0 0 0 1 0 1)2

After shifting right twice = ( 0 0 0 0 0 0 1 0)2

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-16
C- Programming Fundamentals of C-programming

After shifting right thrice = ( 0 0 0 0 0 0 0 1)2 =(1)10

• Logical operators: -
o Logical operators are used to evaluate conditions or expressions.
o The logical operators are AND and OR.
1. AND Operator (&)
o The AND operators checks for all conditions to be true then only it returns true else false.
o For example, a statement
o y >5 && y <10;
o will result in “true” i.e., 1 if the value of y is greater than 5 AND less than 10, else it will result
in false i.e.,0
2. OR Operator: -
o The OR operator checks for any one or all conditions from the given conditions to be true then
it evaluates true.
o Otherwise, if all conditions are false then it returns false.
o For example, a statement
o y >5 || y <10;
o will result in “true” i.e., 1 if the value of y is greater than 5 OR less than 10, else it will result
in false i.e.,0

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-17
C- Programming Fundamentals of C-programming

• Relational Operator:
o The relational operators are used to test the relation between two variables or a variable
and constant.
o The operators like

< less than


> greater than
== equality operator
<= less than equal to
>= greater than equal to
!= not equal to

• Assignment Operators and Statements:


o These operators are used to assign the value of the expression or variable on the right of
the assignment operator to the variable on its left.
E.g., b = 10;
o Assigning the value of 10 to variable b.
E.g., a += b means a=a + b similarly we can apply multiplication & division operators.

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-18
C- Programming Fundamentals of C-programming

Conditional Operators
o Conditional operator is also known as ternary operator.
o The operator that requires three operands is called as ternary operator.
o Syntax:
(Condition)? Expr1: Expr2;
o It checks for the condition if condition is true then expr1 will be executed otherwise expr2 will be
executed.
E.g., max= (a > b)? a: b;
o This will put the value of a into max if condition is true else the value of b into max.

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-19
C- Programming Fundamentals of C-programming

Program: Write a program to accept two numbers from user and display
greatest of two numbers using conditional operator.

#include<stdio.h>
#include<conio.h>
Void main()
{
int n1, n2, greater;
printf(“Enter a two number”);
scanf(“%d %d”,&n1,&n2);
greater=(n1>n2)? n1: n2;
printf(“The greater number is: %d”,greater);
getch();
}

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-20
C- Programming Fundamentals of C-programming

Program: Write a program to accept three numbers from user and display the
greatest of three using the conditional operator.

#include <stdio.h>
#include <conio.h>
void main()
{
int n1,n2,n3,greater;
clrscr();
printf(“enter three numbers\n”);
scanf(“%d %d %d”,&n1,&n2,&n3);
greater = (n1>n2)?((n1>n3)?n1:n3): ((n2>n3)?n2:n3));
printf(“the largest number is : %d ”,greater);
getch();
}

output:

enter three numbers


234
23
33
the largest number is: 234

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-21
C- Programming Fundamentals of C-programming

Use of Standard (Input and Output) Functions


• Inbuilt IO functions are available in C for displaying data on the standard output device i.e., monitor
and accepting the input from the standard input device i.e. keyboard.
• These IO functions are classified as formatted functions and unformatted functions

1. Formatted IO Functions
• Two formatted IO functions in C
o printf() :- display a data on monitor.
o scanf() :- accept data from keyboard.
printf():

The printf statement allows you to send output to screen


Syntax:

printf(“Format string”, list of variables or expressions)


Format specifiers

Sr. Format specifier Data type


No.
1 %d For integer type of data
2 %f For float type of data
3 %c For char type of data
4 % lf For double type of data
5 % Lf For long double type of data

Example:

printf(“ The simple interest is %f”, si);


This statement will print the output where the format specifier % f will be replaced with the
float type value of the variable si.

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-22
C- Programming Fundamentals of C-programming

scanf():
Syntax:

scanf(“format String”, address of variables);


The address of the variable is obtained with the help of the address of operator (&).
Example:

scanf(“% d”, &x);


This statement is used to accept a int type value from user in the variable x.
2. Unformatted IO Functions
• The unformatted IO functions do not have any format specifier. They are mostly used to accept
and display only one character or a string (string is a set of characters to make a word or
sentence).

• The different unformatted IO functions are listed below:


1. getch ():
This function is used accept one character from the user.
2. getche ():
This function is used accept one character from the user and echo it to screen (accept input
without pressing enter).
3. getchar ():
This function is used to accept one character from the user and echo it (display it on the screen)
and also wait after that for the user to press the enter key.
4. gets ():
This function is used to accept a string from the user. We will see in details of this when studying
the chapter on strings.
5. putch() or putchar() :
These functions are used to display a character on the monitor.
6. puts:
This function is used to display a string on the monitor.

ERROR
While writing c programs, errors also known as bugs in the world of programming may occur
unwillingly which may prevent the program to compile and run correctly as per the expectation of the
programmer.

Basically, there are three types of errors in c programming:

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-23
C- Programming Fundamentals of C-programming

1. Runtime Errors
2. Compile Errors
3. Logical Errors
C Runtime Errors
• C RUNTIME ERRORS are those errors that occur during the execution of a c program.

• Errors which occur during program execution(run-time) after successful compilation are called
run-time errors, One of the most common run-time errors are

• Dividing a number by zero

• Trying to open a file which is not created

• Lack of free memory space

• These types of error are hard to find as the compiler doesn’t point to the line at which the error
occurs.
Compile Errors
• Compile errors are those errors that occur at the time of compilation of the program. C compile
errors may be further classified as:
A. Syntax Error
B. Semantic Error
A. Syntax Error
When the rules of the c programming language are not followed, the compiler will show syntax errors.

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-24
C- Programming Fundamentals of C-programming

Logical Errors
• Logical errors are the errors in the output of the program. The presence of logical errors leads to
undesired or incorrect output and are caused due to error in the logic applied in the program to
produce the desired output.

• Also, logical errors could not be detected by the compiler, and thus, programmers has to check
the entire coding of a c program line by line.

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-25
C- Programming Fundamentals of C-programming

Program: C Program to Calculate Simple Interest.

#include<stdio.h>
#include<conio.h>
void main()
{
float p,r,n,si;
clrscr();
printf("\nEnter the profit, rate & no of yr\n\n ");
scanf("%f%f%f",&p,&r,&n);
si=(p*r*n)/100;
printf("\nSimple Intrest=%f",si);
getch();
}

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-26
C- Programming Fundamentals of C-programming

Program: WAP for swapping of two number.

#include<stdio.h>
int main()
{
int a,b,temp;
printf("Enter any two integers: ");
scanf("%d%d",&a,&b);
printf("Before swapping: a = %d, b=%d",a,b);
temp = a;
a = b;
b = temp;
printf("\nAfter swapping: a = %d, b=%d",a,b);
return 0;
}

output:

Enter any two integers: 5 8


Before swapping: a =5, b=8
Before swapping: a =8, b=5

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-27
C- Programming Fundamentals of C-programming

Program: Write a Program to swap values of two integers without using a


temporary variable.

#include <stdio.h>
#include <conio.h>
void main()
{
int x , y ;
printf("Enter two integers: ") ;
scanf("%d %d" , &x , &y) ;
printf("x=%d y=%d \n" , x , y) ;
x=x+y ;
y=x-y ;
x=x-y ;
printf("After swapping: \n") ;
printf("x=%d y=%d" , x , y) ;
getch() ;
}

output:

Enter two integers: 5 8


x=5 y=8
After swapping:
x=8 y=5

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-28
C- Programming Fundamentals of C-programming

Program: WAP to accept the length and breadth of a rectangle from the user.
Calculate and display the area and perimeter.

#include<stdio.h>
#include<conio.h>
void main ()
{
float length, breadth, area, perimeter; clrscr():
printf (“Enter the length and breadth of the rectangle:”);
scanf(“%f%f”, &lenghth, & breadth);
area = length * breadth;
perimeter = 2* (length + breadth);
printf(“The area of rectangle is = % f and its perimeter is = % f”, area,
perimeter);
getch();
}

output:

Enter the length and breadth of the rectangle: 10


15
The area of rectangle is 150.000000 and its perimeter is =
50.000000

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-29
C- Programming Fundamentals of C-programming

Program: WAP that calculates the roots of quadratic equation.

#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, c;
float x1,x2;
clrscr(0;
printf (Enter the coefficients of the quadratic equation :”);
scanf (“%d”%d%”,&a,&b,&c);
x1=(-b+pow((b*b-4*a*c),0.5)))/2*a;
x2=(-b-pow((b*b-4*a*c),0.5)))/2*a;
printf (“the roots of quadratic equation are :% f and %f”, x1,x2);
getch();
}

Output:

Enter the coefficients of the quadratic equation: 1

3
The roots of quadratic equation are : -1.000000 and -1.000000

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-30
C- Programming Fundamentals of C-programming

Program: WAP that calculates the roots of quadratic equation.

#include<stdio.h>
#include<conio.h>
void main()
{
int x=1;
clrscr();
printf (“%d”%d%d\n”,x,(x=x+2),(x<<2));
x<<2;
printf (“%d”%d%d\n”,++x,++,++x);
getch();
}

Output:

334
644

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-31
C- Programming Fundamentals of C-programming

Questions

1. Write algorithm and draw flowchart to calculate roots of quadratic equations. (6 Marks.) DEC-

13, DEC-18, DEC-17

2. Write algorithm to sort set of numbers in ascending order. (6 Marks.) May-13

3. What is algorithm? Which points to consider while writing algorithm?

(4 M arks.) May, DEC-13, MAR-14, May -16

4. What do you mean by efficiency of algorithm? May-13

5. Explain need of flowchart [2 Marks] May-15

6. Explain time complexity of an algorithm [4 M].

7. Explain space complexity of an algorithm [4 M]

8. Draw flow chart for if else and while statement in ‘C’.

9. Define algorithm, write algorithm to check whether given number is Armstrong number or not.

10. Write a note on operators, explain any two operators.

11. What do you mean by tokens in C, explain?

12. Explain bitwise operator with example [DEC-2014, MAY-17]

13. Write a program to accept marks of 5 subjects marks, and display total and average.

14. Write a note on increment and decrement operators.

15. Evaluate following expression: - 3 Marks

i) ! (5+5 > = 10) ans : 0

ii) 5 + 5 = = 10 | | 1 + 3 = = 5 ans: 1

iii) 5.10 || 10 < 20 && 3 < 5 ans: 1

16. Explain logical operators. Write a c program to demonstrate the same. [4M]

17. Explain Ternary operators with example [5 M].

18. Explain bitwise right shift operator, bitwise x-or operator [4 M].

19. Write an explain unformatted IO functions [4 M].

20. Write a program to print binary equivalent of entered decimal number

[5 M] DEC-18

21. Explain gets() and puts() functions of C language, comment on their parameter and return values.

This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg.2-32

You might also like