C Language Tutorials by Ghulam Murtaza Dahar - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

Example of conditional operator

#include <stdio.h>

int main(){

char feb;

int days;

printf("Enter l if the year is leap year otherwise enter 0: ");

scanf("%c",&feb);

days=(feb=='l')?29:28;

/*If test condition (feb=='l') is true, days will be equal to 29. */

/*If test condition (feb=='l') is false, days will be equal to 28. */

printf("Number of days in February = %d",days);

return 0;

}

Find Your Next Great Read

Describe what you're looking for in as much detail as you'd like.
Our AI reads your request and finds the best matching books for you.

Showing results for ""

Popular searches:

Romance Mystery & Thriller Self-Help Sci-Fi Business