Thursday, November 27, 2014

C Program to count the numbers which are lies between 25 and 75 among the numbers passed through command line

/*…………………………………………………………………………………………..
File Name: rec29.c
Program :  C Program to count the numbers which are lies between 25 and 75 among the numbers passed through command line
Author : sujithbaby440@gmail.com
Date : 26-11-2014
..................................................................................................................................................*/
#include<stdlib.h>
#include<stdio.h>
int main(int argc,char *argv[])
{
int i,num,count=0;
for(i=1;i<argc;i++){
num=atoi(argv[i]);
if((num>25)&&(num<75)){
count=count+1;
}
}
printf("Count of numbers between 25 and 75 is %d",count);
return 1;
}
OUTPUT 1:-
[141740@localhost ~]$ ./a.out 36 45 60
Count of numbers between 25 and 75 is 3[141740@localhost ~]$
OUTPUT 2:-
[141740@localhost ~]$ ./a.out 22 36 89 45 55
Count of numbers between 25 and 95 is 4[141740@localhost ~]$

No comments:

Post a Comment