Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int ch,R,G,B,dig,white,black,pixelgray;
- dig=0;
- R=0;
- G=0;
- B=0;
- white=0;
- black=1;
- printf("Enter number:");
- while((ch=getchar()) !='\n'&& ch !=EOF)
- {
- if(ch>='0'&& ch<='9')
- dig++;
- R=(10*R)+(ch-'0');
- }
- printf("R = %d\n", R);
- printf("Enter number:");
- while((ch=getchar()) !='\n'&& ch !=EOF)
- {
- if(ch>='0'&& ch<='9')
- dig++;
- G=(10*G)+(ch-'0');
- }
- printf("G= %d\n",G);
- printf("Enter number:");
- while((ch=getchar()) !='\n'&& ch !=EOF)
- {
- if(ch>='0'&& ch<='9')
- dig++;
- B=(10*B)+(ch-'0');
- }
- printf("B= %d\n",B);
- pixelgray=((0.299*R)+(0.587*G)+(0.114*B));
- printf("the color of grey pixel is %d",pixelgray);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement