Advertisement
kit__kat

Untitled

Nov 20th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int ch,R,G,B,dig,white,black,pixelgray;
  6. dig=0;
  7. R=0;
  8. G=0;
  9. B=0;
  10. white=0;
  11. black=1;
  12.  
  13.  
  14. printf("Enter number:");
  15. while((ch=getchar()) !='\n'&& ch !=EOF)
  16. {
  17. if(ch>='0'&& ch<='9')
  18. dig++;
  19. R=(10*R)+(ch-'0');
  20.  
  21. }
  22. printf("R = %d\n", R);
  23.  
  24. printf("Enter number:");
  25. while((ch=getchar()) !='\n'&& ch !=EOF)
  26. {
  27. if(ch>='0'&& ch<='9')
  28. dig++;
  29. G=(10*G)+(ch-'0');
  30.  
  31. }
  32. printf("G= %d\n",G);
  33.  
  34. printf("Enter number:");
  35. while((ch=getchar()) !='\n'&& ch !=EOF)
  36. {
  37. if(ch>='0'&& ch<='9')
  38. dig++;
  39. B=(10*B)+(ch-'0');
  40.  
  41. }
  42. printf("B= %d\n",B);
  43.  
  44. pixelgray=((0.299*R)+(0.587*G)+(0.114*B));
  45. printf("the color of grey pixel is %d",pixelgray);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement