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

C Appti Day 4

The document contains multiple C code snippets demonstrating various programming concepts such as loops, conditionals, and function calls. Each snippet showcases different behaviors, including the use of 'do-while' loops, recursion, and the effects of modifying variables. The examples also illustrate the output of specific operations, such as the result of 'scanf' and the behavior of character arrays.

Uploaded by

physicstutormcq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

C Appti Day 4

The document contains multiple C code snippets demonstrating various programming concepts such as loops, conditionals, and function calls. Each snippet showcases different behaviors, including the use of 'do-while' loops, recursion, and the effects of modifying variables. The examples also illustrate the output of specific operations, such as the result of 'scanf' and the behavior of character arrays.

Uploaded by

physicstutormcq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

#include <stdlib.h>
#include <stdio.h>
enum {false, true};
int main()
{
int i = 1;
do
{
printf("%d\n", i);
i++;
if (i < 15)
continue;
} while (false);

getchar();
return 0;
}
---------------------------------------
2.

#include <stdlib.h>
#include <stdio.h>
enum {false, true};
int main()
{
int i = 1;
do
{
printf("%d\n", i);
i++;
if (i < 15)
break;
} while (true);

getchar();
return 0;
}
-------------------------------------------
3.

#include<stdio.h>
int main()
{
static int i=5;
if(--i){
main();
printf("%d ",i);
}
}
--------------------------------------------
4.

#include<stdio.h>
int main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}
-------------------------------------------
5.

#include<stdio.h>
int main()
{
int x;
printf("%d",scanf("%d",&x));
/* Suppose that input value given for above scanf is 20 */
return 1;
}
--------------------------------------------------
6.

# include <stdio.h>
int main()
{
int i=0;
for(i=0; i<20; i++)
{
switch(i)
{
case 0:
i+=5;
case 1:
i+=2;
case 5:
i+=5;
default:
i+=4;
break;
}
printf("%d ", i);
}

getchar();
return 0;
}
------------------------------------------------
7.

int main(){
char k=127;
k=k+1;
printf("d",k);
return 0;
}
-----------------------------------------------
8.
int main(){
if(0)
printf("C");
else if(-1)
printf("C++");
else
printf("JAVA");
return 0;
}

-----------------------------------------
9.

int main()
{
int x = -10;
while (x++ != 0)
;
printf("%d ", x);
return 0;
}
-------------------------------------------
10.
int main(){
char a[]="\0";
if(printf("%s",a))
printf("C");
else
printf("C++");
return 0;
}

You might also like