1(a).An algorithm is a step-by-step method of solving a problem.
Properties:
1.Finiteness- an algorithm should have finite number of steps.
2.Definiteness-any step of an algorithm should be definite and unambiguous.
3.Effectiveness-an algorithm should be effective in solving the problem that it’s meant for.
4.Input-it should have zero or more inputs.
5.Output-it should have 1 or more outputs.
(b).Conditional Operator
Conditional operator takes three operands and consists of two symbols and : . Conditional operators are used for decision making in C. For example:
c=(c>0)?10:-10;
If c is greater than 0, value of c will be 10 but, if c is less than 0, value of c will be -10.
Bitwise Operators
A bitwise operator works on each bit of data. Bitwise operators are used in bit level programming.
Operators Meaning of operators
& Bitwise AND
| Bitwise OR
^ Bitwise exclusive OR
~ Bitwise complement
>> Shift right
2.Pseudocode is an artificial and informal language that helps programmers develop algorithms. Pseudocode is a “text-based” detail (algorithmic) design tool.
The rules of Pseudocode are reasonably straightforward. All statements showing “dependency” are to be indented. These include while, do, for, if, switch. Examples below will illustrate this notion.
The Essay on Patented Algorithms
Software consists of lists of instructions that a computer reads and executes. The tasks done by a computer are largely repetitive; the same chunks of instructions are executed many times. Each chunk performs one specific task and goes by the label algorithm, a method for accomplishing a specific task. In the United States, it is possible to obtain a patent for a software algorithm. One example of ...
1.. If student’s grade is greater than or equal to 60
Print “passed”
else
Print “failed”
OR
RULES FOR PSEUDOCODE
1. Write only one stmt per line
Each stmt in your pseudocode should express just one action for the computer.
2. Capitalize initial keyword
In the example above, READ and WRITE are in caps. There are just a few
keywords we will use:
READ, WRITE, IF, ELSE, ENDIF, WHILE, ENDWHILE, REPEAT, UNTIL
LOOPING: indent the statements that fall inside the loop, but not the keywords
that form the loop
PSEUDOCODE:
READ name, hourlyRate, hoursWorked
grossPay = hourlyRate * hoursWorked
IF grossPay >= 100
deduction = grossPay * deductionRate
ELSE
deduction = 0
ENDIF
netPay = grossPay – deduction
WRITE name, grossPay, deduction, netPay
4. End multiline structures
See how the IF/ELSE/ENDIF is constructed above. The ENDIF (or END
whatever) always is in line with the IF (or whatever starts the structure).
5. Keep stmts language independent
Resist the urge to write in whatever language you are most comfortable with. In
the long run, you will save time! There may be special features available in the
language you plan to eventually write the program in; if you are SURE it will be
written in that language, then you can use the features. If not, then avoid using
the special features.
(b).ADVANTAGES AND DISADVANTAGES
Pseudocode Disadvantages
· It’s not visual
· There is no accepted standard, so it varies widely from company to company
Pseudocode Advantages
· Can be done easily on a word processor
· Easily modified
· Implements structured concepts well
5(a).Operators are the symbol which operates on value or a variable. For example: + is a operator to perform addition.
C programming language has wide range of operators to perform various operations.For better understanding of operators,
these operators can be classified as:
Operators in C programming
Arithmetic Operators
Increment and Decrement Operators
Assignment Operators
The Term Paper on Second Language Aquisition
Language Acquisition What is Second Language Acquisition? In second language learning, language plays an institutional and social role in the community. It functions as a recognized means of communication among members who speak some other language as their native tongue. In foreign language learning, language plays no major role in the community and is primarily learned in the classroom. The ...
Relational Operators
Logical Operators
Conditional Operators
Bitwise Operators
Special Operators
Arithmetic Operators
Operator Meaning of Operator
+ addition or unary plus
– subtraction or unary minus
* multiplication
/ division
% remainder after division( modulo division)
Increment and decrement operators
In C, ++ and — are called increment and decrement operators respectively. Both of these operators are unary operators,
i.e, used on single operand. ++ adds 1 to operand and — subtracts 1 to operand respectively. For example:
Let a=5 and b=10
a++; //a becomes 6
a–; //a becomes 5
++a; //a becomes 6
–a; //a becomes 5
Difference between ++ and — operator as postfix and prefix
When i++ is used as prefix(like: ++var), ++var will increment the value of var and then return it but, if ++ is used as
postfix(like: var++), operator will return the value of operand first and then only increment it.
Assignment Operators
The most common assignment operator is =. This operator assigns the value in right side to the left side. For example:
var=5 //5 is assigned to var
a=c; //value of c is assigned to a
5=c; // Error! 5 is a constant.
Operator ExampleSame as
= a=b a=b
+= a+=b a=a+b
-= a-=b a=a-b
*= a*=b a=a*b
/= a/=b a=a/b
%= a%=b a=a%b
Relational Operator
Relational operators checks relationship between two operands. If the relation is true, it returns value 1 and if the relation is false, it returns value 0. For example:
a>b
Here, > is a relational operator. If a is greater than b, a>b returns 1 if not then, it returns 0.
The Essay on Composing Exercise Program
This is a composing exercise program. This will only work on the computer. The way this program works is very simple. All the poems from Shijing have already been stored within the application itself, and users can choose and open any poems that they want among the list. Since the Shijing has over hundreds of poems, they have been classified according to categories to facilitate the search. The ...
Relational operators are used in decision making and loops in C programming.
OperatorMeaning of OperatorExample
==Equal to5==3 returns false (0)
>Greater than5>3 returns true (1)
!=Not equal to5!=3 true(1)
>=Greater than or equal to5>=3 returns true (1)
Logical Operators
Logical operators are used to combine expressions containing relation operators. In C, there are 3 logical operators:
OperatorMeaning of OperatorExample
&&Logial AND If c=5 and d=2 then,((c==5) && (d>5)) returns false.
||Logical ORIf c=5 and d=2 then, ((c==5) || (d>5)) returns true.
! Logical NOTIf c=5 then, !(c==5) returns false.
Explanation
For expression, ((c==5) && (d>5)) to be true, both c==5 and d>5 should be true but, (d>5) is false in the
given example. So, the expression is false. For expression ((c==5) || (d>5)) to be true, either the expression
should be true. Since, (c==5) is true. So, the expression is true. Since, expression (c==5) is true, !(c==5) is false.
then conditional and bitwise operators.
The sizeof operator
It is a unary operator which is used in finding the size of data type, constant, arrays, structure etc.
(b).bit abit ba ^ b (a XOR b)
000
011
101
110
The Bitwise EX-OR (Exclusive Or) performs a logical EX-OR function, or in more simple terms,
adds the two bits while discarding the carry. The result is zero only when we have 2 zeroes or
ones to perform on.[3] Sometimes EX-OR might just be used to toggle the bits between 1 and 0.
Thus: i = i ^ 1 when used in a loop toggles its values between 1 and 0. [4]
#include
int main()
{
unsigned int x = 3, y = 1, sum, carry;
sum = x ^ y; // Ex – OR x and y
carry = x & y; // AND x and y
while (carry != 0) {
carry = carry
x = sum; // initialize x as sum
y = carry; // initialize y as carry
sum = x ^ y; // sum is calculated
carry = x & y; /* carry is calculated, the loop condition is
The Term Paper on Cgi Program Document Sgml File
A general model of publication Although the medium and the material may differ vastly, essentially the same common process is always involved in publication (Fig. 1). For on-line publications this model makes it possible to automate many of the steps involved (see module on Automated document processing). Figure 1. A model for the publication process. The same general pattern of steps occurs ...
evaluated and the process is repeated until
carry is equal to 0. */
}
printf(“%d “, sum); // the program will print 4
return 0;
7.(b).Use a flowchart to represent the logic of your program before coding.This will reduce lot of redundancy
and helps improve your logic. In fact, even if you don’t use a flow chart, but sure to spend some time thinking
about your program design before diving in and writing code.conditional statements are easy to analyze.
(c).The development of a “C” program involves the use of the following programs in the order of their usage
Editor
This program is used for Writing the Source Code, the first thing that any programmer writing a program in any
language would be doing.
Debugger
This program helps us identify syntax errors in the source code.
Pre Processer
There are certain special instructions within the source code identified by the # symbol that are carried on by a
special program called a preprocessor.
Compiler
The process of converting the C source code to machine code and is done by a program called Compiler.
Linker
The machine code relating to the source code you have written is combined with some other machine code to
derive the complete program in an executable file. This is done by a program called the linker.
(d).If we adopt a modular approach then we will naturally want to keep variable definitions, function prototypes etc
. with each module. However what if
several modules need to share such definitions?
It is best to centralise the definitions in one file and share this file amongst the modules. Such a file is usually called a header file.
Convention states that these files have a .h suffix.
We have met standard library header files already e.g:
#include
The Essay on Loyalty Program And File Import Node
* A supermarket is offering a new line of organic products. The supermarket’s management wants to determine which customers are likely to purchase these products. * The supermarket has a customer loyalty program. As an initial buyer incentive plan, the supermarket provided coupons for the organic products to all of their loyalty program participants and collected data that includes whether or not ...
We can define our own header files and include then our programs via:
#include “my_head.h”
NOTE: Header files usually ONLY contain definitions of data types,
function prototypes and C preprocessor commands.
9(b).Documentation Section Link Section Definition Section Global Declaration Section main()
{ Declaration Section Executable part } Subprogram section Function 1 Function 2 . . function n – S
12(a).The output function is printf() :
Ex: printf(“Enter the value of n”);
The input function is
scanf()..
To read an integer use
scanf(“%d”,&n) entered value is stored in n