C language Programs
SEE THE BEOLW PROGRAMS AND EXPECT THE CORRECT OUT PUTS
void
main(){
int const * p=5;
printf("%d",++(*p));
}
*********************************************************
main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
*********************************************************
main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love U");
else
printf("I hate U");
}
*********************************************************
main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}
*********************************************************
void
main(){
int b,x,y,z;
clrscr();
x=1;
y=2;
z=3;
if((x>1)||(y>1))
if(z>1)
printf("ok\n");
else
if((x>1) && (z>3))
printf("bye\n");
printf("hello" );
}
*********************************************************
main()
{
float balance=1000.0,loan;
loan=balance/10;
if((balance>500)||(loan<500))
printf("good");
if(balance<500)||(loan<500)
printf("caution");
}
*********************************************************
main()
{
float balance=1000.0,loan;
loan=balance/10;
if((balance>500)||(loan<500))
printf("good");
if((balance<500)||(loan<500))
printf("caution");
}
*********************************************************
main()
{
double c;
clrscr();
scanf("%c",c);
}
*********************************************************
main()
{
char ch;
clrscr();
scanf("%c",&ch);
switch(ch)
{
case 'r': printf("red");
case 'w': printf("wite");
default: printf("defau");
break;
}
}
*********************************************************
main()
{
int c=- -2;
printf("c=%d",c);
}
*********************************************************
#define
int charmain()
{
int i=65;
printf("sizeof(i)=%d",sizeof(i));
}
*********************************************************
main()
{
int i=10;
i=!i>14;
Printf ("i=%d",i);
}
*********************************************************
#include
<stdio.h>main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
}
*********************************************************
#include
<stdio.h>main()
{
int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} };
int *p,*q;
p=&a[2][2][2];
*q=***a;
printf("%d----%d",*p,*q);
}
*********************************************************
#include
<stdio.h>main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s;
printf("%d",s->x);
printf("%s",s->name);
}
*********************************************************
#include
<stdio.h>main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
}
*********************************************************
main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}
*********************************************************
main()
{
int i=5;
printf("%d%d%d%d%d%d",i++,i--,++i,--i,i);
}
*********************************************************
#define
square(x) x*xmain()
{
int i;
i = 64/square(4);
printf("%d",i);
}
*********************************************************
main()
{
printf("%p",main);
}
*********************************************************
main()
{
clrscr();
}
clrscr();
*********************************************************
enum
colors {BLACK,BLUE,GREEN}main()
{
printf("%d..%d..%d",BLACK,BLUE,GREEN);
return(1);
}
*********************************************************
void
main(){
char far *farther,*farthest;
printf("%d..%d",sizeof(farther),sizeof(farthest));
}
*********************************************************
main()
{
char *p;
p="Hello";
printf("%c\n",*&*p);
}
*********************************************************
main()
{
static char names[5][20]={"pascal","ada","cobol","fortran","perl"};
int i;
char *t;
t=names[3];
names[3]=names[4];
names[4]=t;
for (i=0;i<=4;i++)
printf("%s",names[i]);
}
*********************************************************
void
main(){
int i=5;
printf("%d",i++ + ++i);
}
*********************************************************
void
main(){
int i=5;
printf("%d",i+++++i);
}
*********************************************************
main()
{
int i;
printf("%d",scanf("%d",&i)); // value 100 is given as input here
}
*********************************************************
#define
f(g,g2) g##g2main()
{
int var12=100;
printf("%d",f(var,12));
}
*********************************************************
main()
{
int i=0;
for(;i++;printf("%d",i)) ;
printf("%d",i);
}
*********************************************************
#include
<stdio.h>main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
}
*********************************************************
#include
<stdio.h>main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s=malloc(sizeof(struct xx));
printf("%d",s->x);
printf("%s",s->name);
}
*********************************************************
#include
<stdio.h>main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
}
*********************************************************
main()
{
extern int i;
i=20;
printf("%d",sizeof(i));
}
*********************************************************
main()
{
printf("%d", out);
}
int out=100;
*********************************************************
main()
{
extern out;
printf("%d", out);
}
int out=100;
*********************************************************
main()
{
show();
}
void show()
{
printf("I'm the greatest");
}
*********************************************************
main( )
{
int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}};
printf("%u %u %u %d \n",a,*a,**a,***a);
printf("%u %u %u %d \n",a+1,*a+1,**a+1,***a+1);
}
*********************************************************
main( )
{
char *q;
int j;
for (j=0; j<3; j++) scanf("%s" ,(q+j));
for (j=0; j<3; j++) printf("%c" ,*(q+j));
for (j=0; j<3; j++) printf("%s" ,(q+j));
}
*********************************************************
main( )
{
void *vp;
char ch = ‘g’, *cp = "goofy";
int j = 20;
vp = &ch;
printf("%c", *(char *)vp);
vp = &j;
printf("%d",*(int *)vp);
vp = cp;
printf("%s",(char *)vp + 3);
}
*********************************************************
main ( )
{
static char *s[ ] = {"black", "white", "yellow", "violet"};
char **ptr[ ] = {s+3, s+2, s+1, s}, ***p;
p = ptr;
**++p;
printf("%s",*--*++p + 3);
}
*********************************************************
main()
{
int i, n;
char *x = "girl";
n = strlen(x);
*x = x[n];
for(i=0; i<n; ++i)
{
printf("%s\n",x);
x++;
}
}
*********************************************************
main()
{
int i=-1;
+i;
printf("i = %d, +i = %d \n",i,+i);
}
*********************************************************
void
main(){
struct{
char name[20];
float x;
}ab;
clrscr();
scanf("%s %f",ab.name,&ab.x);
printf("%s%f",ab.name,ab.x);
}
*********************************************************
#define
two(x) x+x#define
ddouble(x) x+xmain()
{
int sum,num,product;
clrscr();
num=1;
sum=-two(num);
-sum;
product=-ddouble(num);
printf("%5d%5d",sum,product);
}
*********************************************************
main()
{
char s[33];
clrscr();
scanf("%[^\n]",s);
printf("%s",s);
}
*********************************************************
void
main(){
int sum,index;
-index=50;
while(index>=0)
{
sum=sum/index;
-index;
}
}
*********************************************************
void
main(){
int b,x,y,z;
clrscr();
x=1;
y=2;
z=3;
if((x>1)||(y>1))
if(z>1)
printf("ok\n");
else
if((x>1) && (z>3))
printf("bye\n");
printf("hello" );
}
*********************************************************
main()
{
float balance=1000.0,loan;
loan=balance/10;
if((balance>500)||(loan<500))
printf("good");
if(balance<500)||(loan<500)
printf("caution");
}
*********************************************************
main()
{
float balance=1000.0,loan;
loan=balance/10;
if((balance>500)||(loan<500))
printf("good");
if((balance<500)||(loan<500))
printf("caution");
}
*********************************************************
main()
{
double c;
clrscr();
scanf("%c",c);
}
*********************************************************
main()
{
char ch;
clrscr();
scanf("%c",&ch);
switch(ch)
{
case 'r': printf("red");
case 'w': printf("wite");
default: printf("defau");
break;
}
}
*********************************************************
main()
{
int c;
clrscr();
scanf("%d",&c);
while((c>0)&&(c<60))
{
printf("%d",c);
c++;
}
}
*********************************************************
main()
{
int i,found,false;
clrscr();
found=false;
for(i=1;i<=50&&found==false;i++)
printf("%d",i) ;
}
*********************************************************
main()
{
int a,b,c,z;
clrscr();
scanf("%d%d%d",&a,&b,&c);
printf("%d%d%d",a,b,c);
}
*********************************************************
main()
{
int a;
float b;
char c;
clrscr();
scanf("%3d%5f%c",&a,&b,&c);
printf("%3d %5f %c",a,b,c);
}
*********************************************************
main()
{
int d;
float f;
char s[100];
clrscr();
scanf("%s,%*d,%f",s,&d,&f);
printf("%s %d %f",s,d,f);
}
*********************************************************
main()
{
int d=12345;
float f=145.678;
clrscr();
printf("%3d,%5d,%8d",d,d,d);
}
struct cir
{
float ra;
struct point centre;
}cir 1;
struct point
{
int x;
int y;
}
*********************************************************
main()
{
int d=12345;
float f=145.678;
clrscr();
printf("%3d,%5d,%8d",d,d,d);
}
*********************************************************
main()
{
int i=0;
char cl='a';
clrscr();
while(cl>='a'&&cl<='z')
{
cl++;
i++;
printf("%d",i);
}
}
*********************************************************
main()
{
int a,x,n;
scanf("%d",&a);
x=test(a);
printf("%d",x);
}
test(int n)
{
int i;
long int prod=1;
if(n>1)
for(i=2;i<=n;i++)
prod*=i;
return(prod);
}
*********************************************************
main()
{
int a,x,n,b;
scanf("%d%d",&a,&b);
x=test(a,b);
printf("%d",x);
}
test(int n,int m)
{
int z;
z=(nm(n)>=nm(m))?n:m;
return(z);
}
*********************************************************
void
main(){
char a[20];
clrscr();
scanf("%[^\n]",a);
printf("%s",a);
}
*********************************************************
void
main(){
char a[20];
clrscr();
scanf("%[^\n]",a);
printf("%s",a);
}
*********************************************************
#include
<stdio.h>void test(void)
{
char c;
clrscr();
if((c=getchar())!='\n')
test();
putchar(c);
}
main()
{
clrscr();
test();
}
*********************************************************
main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
*********************************************************
main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love U");
else
printf("I hate U");
}
*********************************************************
main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}
*********************************************************
void
main(){
int b,x,y,z;
clrscr();
x=1;
y=2;
z=3;
if((x>1)||(y>1))
if(z>1)
printf("ok\n");
else
if((x>1) && (z>3))
printf("bye\n");
printf("hello" );
}
*********************************************************
main()
{
float balance=1000.0,loan;
loan=balance/10;
if((balance>500)||(loan<500))
printf("good");
if(balance<500)||(loan<500)
printf("caution");
}
*********************************************************
main()
{
float balance=1000.0,loan;
loan=balance/10;
if((balance>500)||(loan<500))
printf("good");
if((balance<500)||(loan<500))
printf("caution");
}
*********************************************************
main()
{
double c;
clrscr();
scanf("%c",c);
}
*********************************************************
main()
{
char ch;
clrscr();
scanf("%c",&ch);
switch(ch)
{
case 'r': printf("red");
case 'w': printf("wite");
default: printf("defau");
break;
}
}
*********************************************************
main()
{
int c=- -2;
printf("c=%d",c);
}
*********************************************************
#define
int charmain()
{
int i=65;
printf("sizeof(i)=%d",sizeof(i));
}
main()
{
int i=10;
i=!i>14;
Printf("i=%d",i);
}
*********************************************************
#include
<stdio.h>main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
}
*********************************************************
#include
<stdio.h>main()
{
int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} };
int *p,*q;
p=&a[2][2][2];
*q=***a;
printf("%d----%d",*p,*q);
}
*********************************************************
#include
<stdio.h>main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s;
printf("%d",s->x);
printf("%s",s->name);
}
*********************************************************
#include
<stdio.h>main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
}
*********************************************************
main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}
*********************************************************
main()
{
int i=5;
printf("%d%d%d%d%d%d",i++,i--,++i,--i,i);
}
*********************************************************
#define
square(x) x*xmain()
{
int i;
i = 64/square(4);
printf("%d",i);
}
*********************************************************
main()
{
printf("%p",main);
}
*********************************************************
main()
{
clrscr();
}
clrscr();
*********************************************************
enum
colors {BLACK,BLUE,GREEN}main()
{
printf("%d..%d..%d",BLACK,BLUE,GREEN);
return(1);
}
*********************************************************
void
main(){
char far *farther,*farthest;
printf("%d..%d",sizeof(farther),sizeof(farthest));
}
*********************************************************
main()
{
char *p;
p="Hello";
printf("%c\n",*&*p);
}
*********************************************************
main()
{
static char names[5][20]={"pascal","ada","cobol","fortran","perl"};
int i;
char *t;
t=names[3];
names[3]=names[4];
names[4]=t;
for (i=0;i<=4;i++)
printf("%s",names[i]);
}
*********************************************************
void
main(){
int i=5;
printf("%d",i++ + ++i);
}
*********************************************************
void
main(){
int i=5;
printf("%d",i+++++i);
}
*********************************************************
main()
{
int i;
printf("%d",scanf("%d",&i)); // value 100 is given as input h ere
}
*********************************************************
#define
f(g,g2) g##g2main()
{
int var12=100;
printf("%d",f(var,12));
}
*********************************************************
main()
{
int i=0;
for(;i++;printf("%d",i)) ;
printf("%d",i);
}
*********************************************************
#include
<stdio.h>main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
}
*********************************************************
#include
<stdio.h>main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s=malloc(sizeof(struct xx));
printf("%d",s->x);
printf("%s",s->name);
}
*********************************************************
#include
<stdio.h>main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
}
*********************************************************
main()
{
extern int i;
i=20;
printf("%d",sizeof(i));
}
*********************************************************
main()
{
printf("%d", out);
}
int out=100;
*********************************************************
main()
{
extern out;
printf("%d", out);
}
int out=100;
*********************************************************
main()
{
show();
}
void show()
{
printf("I'm the greatest");
}
*********************************************************
main( )
{
int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}};
printf("%u %u %u %d \n",a,*a,**a,***a);
printf("%u %u %u %d \n",a+1,*a+1,**a+1,***a+1);
}
*********************************************************
main( )
{
int a[ ] = {10,20,30,40,50},j,*p;
for(j=0; j<5; j++)
{
printf("%d" ,*a);
a++;
}
p = a;
for(j=0; j<5; j++)
{
printf("%d " ,*p);
p++;
}
}
*********************************************************
main( )
{
char *q;
int j;
for (j=0; j<3; j++) scanf("%s" ,(q+j));
for (j=0; j<3; j++) printf("%c" ,*(q+j));
for (j=0; j<3; j++) printf("%s" ,(q+j));
}
*********************************************************
main( )
{
void *vp;
char ch = ‘g’, *cp = "goofy";
int j = 20;
vp = &ch;
printf("%c", *(char *)vp);
vp = &j;
printf("%d",*(int *)vp);
vp = cp;
printf("%s",(char *)vp + 3);
}
*********************************************************
main ( )
{
static char *s[ ] = {"black", "white", "yellow", "violet"};
char **ptr[ ] = {s+3, s+2, s+1, s}, ***p;
p = ptr;
**++p;
printf("%s",*--*++p + 3);
}
*********************************************************
main()
{
int i, n;
char *x = "girl";
n = strlen(x);
*x = x[n];
for(i=0; i<n; ++i)
{
printf("%s\n",x);
x++;
}
}
*********************************************************
main()
{
int i=-1;
+i;
printf("i = %d, +i = %d \n",i,+i);
}
*********************************************************
void
main(){
struct{
char name[20];
float x;
}ab;
clrscr();
scanf("%s %f",ab.name,&ab.x);
printf("%s%f",ab.name,ab.x);
}
*********************************************************
#define
two(x) x+x#define
ddouble(x) x+xmain()
{
int sum,num,product;
clrscr();
num=1;
sum=-two(num);
-sum;
product=-ddouble(num);
printf("%5d%5d",sum,product);
}
*********************************************************
void
main(){
int sum,index;
-index=50;
while(index>=0)
{
sum=sum/index;
-index;
}
}
*********************************************************
void
main(){
int b,x,y,z;
clrscr();
x=1;
=2;
=3;
if((x>1)||(y>1))
if(z>1)
printf("ok\n");
else
if((x>1) && (z>3))
printf("bye\n");
printf("hello" );
}
*********************************************************
main()
{
float balance=1000.0,loan;
loan=balance/10;
if((balance>500)||(loan<500))
printf("good");
if(balance<500)||(loan<500)
printf("caution");
}
*********************************************************
main()
{
float balance=1000.0,loan;
loan=balance/10;
if((balance>500)||(loan<500))
printf("good");
f((balance<500)||(loan<500))
printf("caution");
}
*********************************************************
main()
{
double c;
clrscr();
scanf("%c",c);
}
*********************************************************
main()
{
char ch;
clrscr();
scanf("%c",&ch);
switch(ch)
{
case 'r': printf("red");
case 'w': printf("wite");
default: printf("defau");
break;
}
}
*********************************************************
main()
{
int c;
clrscr();
scanf("%d",&c);
while((c>0)&&(c<60))
{
printf("%d",c);
c++;
}
}
*********************************************************
main()
{
int i,found,false;
clrscr();
found=false;
for(i=1;i<=50&&found==false;i++)
printf("%d",i) ;
}
*********************************************************
main()
{
int a,b,c,z;
clrscr();
scanf("%d%d%d",&a,&b,&c);
printf("%d%d%d",a,b,c);
}
*********************************************************
main()
{
int a;
float b;
char c;
clrscr();
scanf("%3d%5f%c",&a,&b,&c);
printf("%3d %5f %c",a,b,c);
}
*********************************************************
main()
{
int d;
float f;
char s[100];
clrscr();
scanf("%s,%*d,%f",s,&d,&f);
printf("%s %d %f",s,d,f);
}
*********************************************************
main()
{
int d=12345;
float f=145.678;
clrscr();
printf("%3d,%5d,%8d",d,d,d);
}
struct cir
{
float ra;
struct point centre;
}cir 1;
struct point
{
int x;
int y;
}
*********************************************************
main()
{
int d=12345;
float f=145.678;
clrscr();
printf("%3d,%5d,%8d",d,d,d);
}
*********************************************************
main()
{
int i=0;
char cl='a';
clrscr();
while(cl>='a'&&cl<='z')
{
cl++;
i++;
printf("%d",i);
}
}
*********************************************************
main()
{
int a,x,n;
scanf("%d",&a);
x=test(a);
printf("%d",x);
}
test(int n)
{
int i;
long int prod=1;
if(n>1)
for(i=2;i<=n;i++)
prod*=i;
return(prod);
}
*********************************************************
main()
{
int a,x,n,b;
scanf("%d%d",&a,&b);
x=test(a,b);
printf("%d",x);
}
test(int n,int m)
{
int z;
z=(nm(n)>=nm(m))?n:m;
return(z);
}
*********************************************************
1..
main()
{
int const * p=5;
printf("%d",++(*p));
}
*********************************************************
main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf(" %c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
*********************************************************
main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf love U");
else
printf("I hate U");
}
*********************************************************
main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}
*********************************************************
main()
{
int c=- -2;
printf("c=%d",c);
}
*********************************************************