Tag Archives: string

C Programming Tutorial – 17 – Short form of if + add a string :

Published by:

Note:

  • //Example for Short form of if+add a string

Code:
—————————

#include <stdio.h>
#include <stdlib.h>

int main()
{

int friends;
printf(“How many friends do you have ? \n”);
scanf(” %d”, &friends);

// If you have 0 or 2 or 3 or … friends it shows s else if you have 1 friend you will not see s.
printf(“You have %d friend%s \n”, friends ,(friends !=1 ) ? “s” : “”);

return 0;

}