#include <stdio.h>
#define IN 1
#define OUT 0
int main(){
int c, nl, nw, nc, state;
state = OUT;
nl = nw = nc = 0;
while((c = getchar()) != EOF){
++nc; /*Count chars*/
if(c == '\n') ++nl; /*Count lines*/
if(c == ' ' || c == '\n' || c == '\t') state = OUT;
else if(state == OUT){
state = IN;
++nw; /*Count words*/
}
}
printf("[Lines: %d]\n[Words: %d]\n[Chars: %d]\n", nl, nw, nc);
return 0;
}
C Funtioncs - Count chars, words and lines
# date
diciembre 20, 2018
C Functions - Multiplication Example
#include <stdio.h>
int multNumbers(int a, int b);
int main(){
int number1 = 3;
int number2 = 4;
int mult;
mult = multNumbers(number1, number2);
printf("mult = %d",mult);
return 0;
}
int multNumbers(int a,int b){
return result a * b;
}
# date
diciembre 14, 2018
Suscribirse a:
Entradas (Atom)