0% found this document useful (0 votes)
250 views3 pages

C Programming Operators Output Analysis

The document provides examples of C code snippets using various operators and formatting specifiers: 1) It shows examples calculating expressions using arithmetic, assignment, increment/decrement operators. 2) Examples demonstrate formatting of different data types like integers, floats, characters using printf format specifiers. 3) Examples also show bitwise operators, string formatting, character input/output using scanf and printf. 4) The last example demonstrates escape sequences and formatting of strings within printf.

Uploaded by

salagram
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
250 views3 pages

C Programming Operators Output Analysis

The document provides examples of C code snippets using various operators and formatting specifiers: 1) It shows examples calculating expressions using arithmetic, assignment, increment/decrement operators. 2) Examples demonstrate formatting of different data types like integers, floats, characters using printf format specifiers. 3) Examples also show bitwise operators, string formatting, character input/output using scanf and printf. 4) The last example demonstrates escape sequences and formatting of strings within printf.

Uploaded by

salagram
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Operators

Find out the output:

a) int x=6,y=3,z=2,ans;
ans= x/y/z;
printf (“ans = %d”, ans);

b) int x=5,y=-2,z;
z= x/y + x++;
printf (“%d\t%d\t%d”, x, y, z);

c) int a=3,b=7,c=0,ans;
ans= a*=b /5 + c--;
printf (“\n%d\t%d\t%d\t%d”, ans, a, b, c,);

d) int x=6,y=4;
float z;
z=x/y;
printf (“z = %f “, z);

e) Assuming the variable of (d)


z=3;
float s=x/z;
printf (“s = %f”, s);
printf (“ans = %f”, z*4);

f) int x=7;
float y=4.5;
printf (“%d”, x+y);
printf (“%f”, x+y);

g) int x=32767;
printf (“%d\t%d”, x+1,x+32769);

h) char x=’a’;
printf (“%d\t%c”, x, x);
printf (“\n%c”, x+2);
i) char x=’2’;
printf (“\n%d\t%d\t%c”, x, 2*x, 2*x);

j) char x, y;
x=’A’+’2’;
printf (“\n%d\t%c”, x, x);

k) int x=7;
printf (“%d\t%d”, x%-3, -x%4);

l) float x=1000000;
printf (“\n%f\t%e\t%g”,x,x,x);

m) int x=20,r=30;
int y=0x20,z=012;
printf (“%d\t%x\%o”, x, x,x);
printf(“%d\t%d”,y+20,z-5);
printf(“%x\t%o”,y,z);
printf(“%X”,r);

n) int x,y;
scanf(“%d*%d”,&x,&y);
printf(“%d\t%d”,x,y);

o) int x=50;
printf (“%d\t%d\t%d”, x++,x++,x++);
printf (“%d\t%d\t%d”, x++, x--,x++);
printf (“%d\t%d\t%d\t%d”, x++, x--,x++,x++);

p) char x;
printf (“Enter a character :”);
scanf (“%d”,&x);
printf (“%c”,x);

q) unsigned int x;
signed int y;
x=-1;y=x;
printf (“%d\t%u”, x, x);
printf (“%d\t%u”, y, y);
printf(“size = %d”,sizeof(x));
r) long int x=100;
short int y=200;
printf(“%d”,sizeof(x));
printf(“%d”,sizeof(y));

s) enum color {RED,GREEN,BLUE,WHITE,YELLOW}


printf(“%d”, WHITE);

t) enum color {RED,GREEN=6,BLUE,WHITE,YELLOW}


printf(“%d”, WHITE);

u) int x=100,y=5;
printf(“%5d%d”,x,y);
printf(“%-5d%d”,x,y);

v) float x=45.678;
printf(“%f\t%6f”,x,x);
printf(“%.2f\t%4.2f”,x,y);

w) char name[]= “Cplusplus”;


int x=10,y=5;
printf(“%s\t%.5s”,name,name);
printf(“%.5s\t%10.*s”, name, x, name);
printf(“%*.*s”, x, y, name);
printf(“%-*.2s”,y,name);

x) char name[20];
scanf(“%[^\n]”,name);
printf(“%s”, name);

y) char name[20];
scanf (“%[^\#]s”, name);
printf (“%s”, name);

printf (“\nit is c\b\\\”Tedious\”\t to learn\n Programming\b\b\b\b Language

You might also like