Tuesday, November 18, 2014

C Programming for Beginners 10 - Switch Statement in C











1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include <stdlib.h>
int main()
{
int marks=75;

switch (marks)
{
case 97:
case 95:
case 90:
case 85:
printf("Excellent");
break;
case 75:
case 70:
printf("Very Good");
break;
case 60:
printf("good");
break;
case 40:
printf("Ok");
break;
default:
printf("Grade unavailable");
}
}










switch Statement (C)

C Programming switch...case Statement -

Switch Case in C and C++

C Tutorial – The if and switch statement

C switch case rules - C Programming

Wednesday, November 12, 2014

C Programming for Beginners 9 - The ternary (conditional) operator in C










 1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>
#include <stdlib.h>
int main()
{
///The ternary (conditional) operator in C
int a=25,b=20;
int c ;
///(/* logical expression goes here */) ? (/* if non-zero (true) */) : (/* if 0 (false) */)
c = (a > b) ? b : a;
printf("ans = %d",c);
}










ternary operator bash
how to use ternary operator in c
associativity of ternary operator in c
Verwandte Suchanfragen zu ternary operator
ternary operator java
ternary operator php
ternary operator c++
ternary operator ruby
ternary operator perl
ternary operator python
javascript ternary operator

Sunday, November 9, 2014

C Programming for Beginners 8 - if...else and Nested if...else stateme...











#include <stdio.h>
#include <stdlib.h>
int main()
{
int age;
printf("Please enter the age ");
scanf("%d",&age);
if (age > 18/* condition goes here */) {
/* if the condition is non-zero (true), this code will execute */
printf("The age is greater then 18 \n");
if(age < 21)
{
printf("The age is greater then 18 but less then 21");
}else{
printf("The age is greater then 18 but not less then 21");
}

} else if (age == 18)
{
printf("The age is equal to 18");
} else
{
printf("The age is not greater then or equal to 18");
}


}

 

© 2013 Klick Dev. All rights resevered.

Back To Top