Switch statement is an extension of if.......else statement. This permits any number of branches. The syntax is
GURU NANAK DEV CO-ED POLYTECHNIC
Friday, 30 September 2011
(iii) Nested if....else statement
This statement is formed by joining if..........else statements either in the if block or in the else block or both. The syntax is
(iii) else.....if statement
else.....if adder statement is used to take multi-way decision. This statement is formed by joining if.......else statements in which each else contains another if......else. The syntax is,
(ii) if....else statement
if........else statement is used to execute one group of statements if the test condition is true or other group if the test condition is false. The syntax is
Decision making statements
Decision making statements are used to skip or to execute a group of statements based on the result of some conditions. The decision making statements are,
(i) Simple if statement
(ii) if.......else statement
(iii) nested if
(iv) switch statement
(i) Simple if statement
The Simple if statement is used to execute or skip one statement or group of statements for a particular condition. The syntax is
if(test condition)
{
statement block;
}
next statement;
When this statement is executed, the computer first evaluates the value of the test condition. If the value is true, statement block and next statement are executed sequentially. If the value is false, statement block is skipped and execution starts from next statement.
Conditions
(i) The opening and closing curl brackets {} are must if the statement block
contains more than one statement.
contains more than one statement.
(ii) The brackets around the test condition are must
(iii) The test condition must be relational or logical expression
(iv) Statement block is called body of the if statement and it contains one or
more statement blocks.
more statement blocks.
#include<stdio.h>
main( )
{
int salary;
char good;
scanf (“%d %c”, &salary,&performance);
if (performance= =‘good’
{
salary=salary+1000;
}
printf(“%d”, salary)’
}
This program tests the performance of an employee. If the performance of an employee in an organization is good, then Rs.1000/- will be added to his salary. For other grades no incentives are added.
C Programming- Assignment Operators
Assignment operators are operators, which are used to simplify the coding of certain type of assignment statement. The syntax is
variable operator = expression
where,
variable - valid user defined name
operator - + - * / %
expression - constant (s)or a variable(s) or operator(s)
Example
The table given below lists the operators with example.
Operator | Meaning |
+= | value of LHS variable will be added to the RHS value and is assigned to LHS variable. |
-= | RHS value will be subtracted from LHS variable and is assigned to LHS variable. |
*= | value of LHS variable will be multiplied by the RHS value and is assigned to LHS variable. |
/= | value of LHS variable will be divided by the RHS value and is assigned to LHS variable. |
%= | value of LHS variable will be divided by RHS value and the remainder will be stored in the LHS variable. |
Wednesday, 14 September 2011
Data Types
Dear students,
I think we are too much concentrating on our practical classes, than that of our theory. Even though, practicals are more important than that of mugging up some text and vomiting it on a piece of paper; we cannot proceed further with programs if we are not convenient in its usage.
Hence, Let us spare time for theoretical discussions also.
Objectives:
In this lesson let us discuss about :
1.declare (name) a local variable as being one of C's five data types
2.initialise local variables
3.perform simple arithemtic using local variables
I think we are too much concentrating on our practical classes, than that of our theory. Even though, practicals are more important than that of mugging up some text and vomiting it on a piece of paper; we cannot proceed further with programs if we are not convenient in its usage.
Hence, Let us spare time for theoretical discussions also.
Objectives:
In this lesson let us discuss about :
1.declare (name) a local variable as being one of C's five data types
2.initialise local variables
3.perform simple arithemtic using local variables
Tuesday, 13 September 2011
HTML Tags / Codes / Web Page Design
|
Wednesday, 31 August 2011
GURU NANAK DEV CO-ED POLYTECHNIC
ROHINI, SECTOR -15, DELHI-85
Phone no. : 011-27860308/27567819
e-mail : gndpoly.delhi@nic.in
The G N D Polytechnic started in 1995 at Pusa Polytechnic Campus. It shifted in its new campus at Sector-15, Rohini in 1997 and was inaugurated by then Chief Minister. The institution has been named after the first Sikh Guru, Guru Nanak Dev.The institution runs in two shifts namely morning and evening. The Morning shift beings at 7.30 a.m. and continues till 3.30 p.m. The evening shift runs from 12.30 p.m. to 8.30 p.m. At present, there are six branches in the morning shift and five in the evening shift with 60 students in each branch.
Principal : Mr. Anil Kumar Choudhary : He is a man of multifaceted personality, academician, scholor, disciplinarian, highly capable, boldly decisive and well versed with administrative work. He graduated in Civil Engg. From Visvesvaraya Regional College of Engineering (now VNIT) Nagpur with first division. With distinctive marks, he post graduated from S.G.S.I.T., Indore in Transportation Engg. He has authored a couple of books on applied Mechanics, Environmental Engg., Hydraulics and Fluid Mechanics. He is stern, strict and brooks no indiscipline. Yet he is endowned with humble and human qualities.
Vice Principal : Dr. R. D. Sharma : He is a mathematician wizard who has penned down a wide range of books which sell like hot cakes among students from sixth standard to post graduate level. He is man of few but very effective words. He stands non pareil (unique) in the department of Science and Humanities. Not only this, he is also a recipient of several awards for his dedication, contribution and perseverance in the field of mathematics.
Monday, 29 August 2011
C - PROGRAM :- LESSON 02
DECLARATION STATEMENT
1. #include <stdio.h>
/*this is a library in the C compiler which is the software where you run the programs.*/
2. int main()
/*this is the main function of the program, the body of the program will be inside this function.*/
3. { int x, y, z;
/*this is the declaration of variables of type integer*/
4.printf("Enter two numbers to multiply(enter a space between numbers): );
/*printf('''); is a function in the compiler which outputs what's in between the " " to the monitor*/
5. scanf("%d%d", &x, &y);
/*scanf(""); is another function except this one inputs what's in between the " " and stores it into the variable for this example x and y*/
6. z = x * y;
/*the = sign is an assignment to the left, so it assigns the product of x and y to the variable z*/
7. printf("The product is : %d", z);
8. return 0;
/*this code is what tells the compiler that you are terminating the program it returns 0 to the operating system*/
9. }
/* this is the closing bracket just like in a math funtion*/
1. #include
/*this is a library in the C compiler which is the software where you run the programs.*/
2. int main()
/*this is the main function of the program, the body of the program will be inside this function.*/
3. { int x, y, z;
/*this is the declaration of variables of type integer*/
4.printf("Enter two numbers to multiply(enter a space between numbers): );
/*printf('''); is a function in the compiler which outputs what's in between the " " to the monitor*/
5. scanf("%d%d", &x, &y);
/*scanf(""); is another function except this one inputs what's in between the " " and stores it into the variable for this example x and y*/
6. z = x * y;
/*the = sign is an assignment to the left, so it assigns the product of x and y to the variable z*/
7. printf("The product is : %d", z);
8. return 0;
/*this code is what tells the compiler that you are terminating the program it returns 0 to the operating system*/
9. }
/* this is the closing bracket just like in a math funtion*/
Saturday, 27 August 2011
5th SEM MECHANICAL & 3rd SEM ECE
OVERVIEW OF C
Elements of C language
C is an efficient and portable general purpose programming language. It was developed in the year 1972 at Bell Telephone Laboratories (AT&T) by Dennis Ritchie. The name C was taken from the second letter of the earlier version BCPL Basic Combined Programming Language developed by Ken Thompson of Bell Laboratories.
Until 1978 C was restricted within Bell laboratories. But after publication of definite description of the language by Brain Kernighan and Ritchie the language began to promote.
Features of C-language
(i) It is a flexible high level structured programming language.
(ii) It includes the features of low level language like assembly language.
(iii) It is portable. A program written for one type of computer can be used in any
other type.
(iv) It is much faster and efficient.
(v) It has an ability to extend itself.
(vi) It has a number of built-in functions, which makes the programming task
simple.
Elements of C language
C is an efficient and portable general purpose programming language. It was developed in the year 1972 at Bell Telephone Laboratories (AT&T) by Dennis Ritchie. The name C was taken from the second letter of the earlier version BCPL Basic Combined Programming Language developed by Ken Thompson of Bell Laboratories.
Until 1978 C was restricted within Bell laboratories. But after publication of definite description of the language by Brain Kernighan and Ritchie the language began to promote.
Features of C-language
(i) It is a flexible high level structured programming language.
(ii) It includes the features of low level language like assembly language.
(iii) It is portable. A program written for one type of computer can be used in any
other type.
(iv) It is much faster and efficient.
(v) It has an ability to extend itself.
(vi) It has a number of built-in functions, which makes the programming task
simple.
Thursday, 25 August 2011
C-PROGRAMMING for Electronics & Comm. Students
PROGRAM-01
AIM:-To write a simple program in "C" to explain the functions of 'printf & getchar' commands
PROGRAM:
/* My First Program in 'C'*/
#include <stdio.h>
main()
{
printf("HELLO WORLD");
getchar();
}
OUTPUT:- HELLO WORLD
RESULT:- Thus a simple program in 'C is written & executed
NOTICE TO THE THIRD SEMESTER ELECTRONICS & COMMUNICATION STUDENTS
NOW YOU CAN DOWNLOAD YOUR COMPUTER PROGRAMMING AND APPLICATIONS FULL LECTURE MATERIAL FROM HERE.
Subscribe to:
Posts (Atom)