How to Track Employee Performance A Comprehensive Guide.pdf
Elements of c program....by thanveer danish
1.
2. Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
Ltd
3. Elements of programming
MUHAMMED THANVEER.M
kutubmadar@gmail.com
www.facebook.com/username
twitter.com/username
in.linkedin.com/in/profilename
9526960445
5. Variables
A variable is nothing but a name given to a storage area that our programs can
manipulate.
Type Description
Char Typically a single octet(one byte).
Int The most natural size of integer for the machine.
Float A single-precision floating point value.
Double A double-precision floating point value.
Void Represents the absence of type.
Example
int i, j, k;
char c, ch;
float f, salary;
double d;
7. if Statement
o powerful decision making statement
o a two-way decision statement
Syntax
if (conditional)
{
block of statements executed if conditional is true;
}
else
{
block of statements if condition false;
}
Example
main()
{
int x=5
if (x > 1)
{
x=x+10;
}
printf("%d", x);
}
8. if…else statement
oExtension of the simple if statement
Syntax
if (condition)
{
True-block statement(s)
}
else
{
False-block statement(s)
}
9. if-else-if statement
EXAMPLE
void main(void)
{
int numb;
printf("Type any Number : ");
scanf("%d", &numb);
if(numb > 0)
{
printf("%d is the positive number", numb);
}
else if(numb < 0)
printf("%d is the Negative number", numb);
else
printf("%d is zero",numb);
}
10. Switch Statement
The switch and case statements help control complex conditional and
branching operations.
Syntax:
switch (expression) {
case item: statements; break;
case item: statements; break;
case item: statements; break;
default: statement; break;
}
11. Example:
#include
main()
{
int numb;
printf("Type any Number");
scanf("%d",&numb);
switch(numb %2)
{
case 0 : printf("the number %d is even ", numb);
case 1 : printf("the number %d is odd ", numb);
break;
}
}
12. Ternary condition
The ? (ternary condition) operator is a more efficient form for
expressing simple if
statements. It has the following form:
expression1 ? expression2: expression3
Example:
res = (a>b) ? a : b;
if a is greater than b than res has the value a else the res has value
b.
13. obreak statement
break statement is used to exit from a loop or a switch, control passing to the
first
statement beyond the loop or a switch.
for(i=0;i<=10;i++)
{
if(i==5)
{
break;
}
printf(" %d",i);
}
14. ocontinue statement
continue statement is a jump statement. it can be used only inside for
loop, while loop and do-while loop
Example
for(i=0;i<10;i++)
{
if(i==5){
continue;
}
printf(" %d",i);
}
15. The goto statement
The goto is a unconditional branching statement used to transfer
control of the program from one statement to another.
Syntax
goto label;
............. .
............
.............
label:
statement;
16. EXAMPLE
#include <stdio.h>
int main ()
{
/* local variable definition */
int a = 10;
/* do loop execution */
LOOP:do
{ if( a == 15)
{
/* skip the iteration */
a = a + 1;
goto LOOP;
}
printf("value of a: %dn", a);
a++;
}
while( a < 20 );
return 0;
}
answer
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 16
value of a: 17
value of a: 18
value of a: 19
17. Loop
A loop statement allows us to execute a statement or group of statements
multiple times
18. If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
19. Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com