while(1)
{
char *smallString = (char *) malloc(10);
}
long long number = 1;
while(1)
number *= 2;
while(1)
{
char hugeString[1000000L];
memset(hugeString, 0, 1000000L);
}
while(1)
{
long *bigArray = (long *) malloc(sizeof(long) * 1000);
memset(bigArray, 1000000, 1000);
(bigArray);
}
int f1 (int a, int b)
{
if (a > b)
{
printf("A is greater than B\n");
return 1;
}
else
{
printf("B is greater than A");
return 0;
}
}
main()
{
if (f1(20,10) || f1(10,20))
printf("C is fun!\n");
}
A is greater then B
C is fun!
A is greater then B
B is greater then A
C is fun!
A is greater then B
B is greater then A
main(){
char c1 ='a';
char c2 = c1+10;
}
struct s {
int i;
struct s *s1;
struct s *s2;
};
for (int i = 0; i>=0, i--){
printf("%d\n", i);
}//end of loop
int i;
for (i=1; i<=10; i++){
printf("%d", i);
}
int i = 10;
while (i>0){
printf("%d\n", i);
i--;
}
int i;
for (i= 10; i>0; i--){
printf("%d\n", i);
}// end of loop
int main(){
int a=1, b=2, c=3, d=4;
int x = a;
if (a>b)
if (b<c) x=b;
else x=c;
return(x);
}
union Cars {
char make[20];
char model[30];
short year;
} car;
main(){
constant int PI = 3.14;
printf("%f\n", pi);
}
___
in the same ___
.
main() {
char c1='a' , c2='A';
int i=c2-c1;
printf("%d", i);
}
char *string[20] = { "one", "two", "three"};
printf("%c", string[1][2]);
printf("%s", string[1][2]);
printf("%s", string[1]);
printf(string[1]);
player.name
(*player).name
*player.name
player.*name
main() {
for(i=0; i<10; i++) ;
}
main() {
int i=0;
for(; i<10; i++) ;
}
main() {
int i;
for(i=0; i<j; i++) ;
}
main() {
int i;
for (i= 10; i<10; i++)
}
1 main() { float x = f1(10, 5); }
2 float f1(int a, int b) { return (a/b); }
#include <stdio.h>
int main() {
int *p = NULL;
return 0;
}
___
?int a=10, b=20;
int f1(a) { return(a*b); }
main() {
printf("%d", f1(5));
}
char *string = "Hello World";
char string = "Hello World";
char string[20] = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'};
char string[] = "Hello World";
#ifdef MYLIB_H
#undef MYLIB_H
// mylib.h content
#endif /* MYLIB_H */
#ifndef MYLIB_H
#define MYLIB_H
// mylib.h content
#endif /* MYLIB_H */
#define MYLIB_H
#include "mylib.h"
#undef MYLIB_H
#ifdef MYLIB_H
#define MYLIB_H
// mylib.h content
#endif /* MYLIB_H */
main(){
int x=1;
while(x++<100){
x*=x;
if(x<10) continue;
if(x>50) break;
}
}
struct a {
void *f1;
};
struct a {
void (*f1)();
};
struct a {
*(void *f1)();
};
struct a {
void *f1();
};
main(){
char *p = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int i;
for (i=0;i<5;i++) *p++; *p++;
printf("%c",*p++);
}
%
**
*
&
void add (int a, int b, int *result)
{
*result = a+b;
}
main()
{
int a = 10;
int b = 20;
int result = 0;
add(a,b,&result);
}
void add (int a, int b, int result)
{
result = a+b;
}
main()
{
int a = 10;
int b = 20;
int result = 0;
add(a,b,result);
}
void add (int a, int b, int *result)
{
result = a+b;
}
main()
{
int a = 10;
int b = 20;
int result = 0;
add(a,b,result);
}
void add (int *a, int *b, int *result)
{
result = a+b;
}
main()
{
int a = 10;
int b = 20;
int result = 0;
add(*a,*b,*result);
}
void fibonacci(int a, int b)
{
int c = a+b;
if(a>100)
return;
printf("%d", a);
fibonacci(a,b);
}
int main()
{
fibonacci(0,1);
}
void fibonacci(int a, int b)
{
int c = a+b;
if(a>100)
return;
printf("%d", b);
fibonacci(a,c);
}
int main()
{
fibonacci(0,1);
}
void fibonacci(int a, int b)
{
int c = a+b;
if(a>100)
return;
printf("%d", a);
fibonacci(b,c);
}
int main()
{
fibonacci(0,1);
}
void fibonacci(int a, int b)
{
int c = a+b;
if(a>100)
return;
printf("%d", c);
fibonacci(b,c);
}
int main()
{
fibonacci(0,1);
}
intern
extern
register
static
i
having the value of 1?for(i=1; i<=1; i++);
for(i=1; i=10; i++);
for(i=1; i==10; i++);
for(i=10; i>=1; i--);
1 main() {
2 int a, b, c;
3 a=10; b=50;
4 c=a * b % a;
5 }
float g;
void *vptr=&g;
f=(float *)vptr;
f=*(float *)vptr;
f=*(float)vptr;
f=(float)*vptr;
hello
. char hello[25];
strcpy(hello, "Hello ");
strcpy(hello, "Mars");
char hello[25];
char *p;
strcpy(hello, "Hello World");
p = hello;
p +=6;
strcpy(p, "Mars");
char *hello;
strcpy(hello, "Hello World");
hello+=6;
strcpy(hello, "Mars");
char hello[25];
strcpy(hello, "Hello World");
strcpy(*hello[6], "Mars");
int fl(int a, int b) { return(a>b?a:b); }
coord point;
point.x = 9;
point.y = 3;
struct coord{
int x;
int y;
};
typedef struct coord coord;
typedef struct coord{
int x;
int y;
};
typedef struct coord{
int x;
int y;
} coord;
typedef struct{
int x;
int y;
} coord;
#include <stdio.h>
#if X == 3
#define Y 3
#else
#define Y 5
#endif
int main()
{
printf("%d", Y);
return 0;
}
[Reference](https://devdocs.io/c/memory/calloc , https://devdocs.io/c/memory/malloc )
#include <stdio.h>
#define L 10
int main(){
int a =10;
switch (a,a<<2){
case L:printf("a==L"); break;
case L*2 : printf("a = L* 2\n"); break;
case L*4 : printf("a = L* 4\n"); break;
default: printf("Error\n");
}
}
a=L*2
a=L
Error
a=L*4
z = x + y * x + 10 / 2 * x;
printf("value is =%d",z);
#include <stdio.h>
void solve() {
int x = 2;
printf("%d", (x << 1) + (x >> 1));
}
int main() {
solve();
return 0;
}
int a=20, b=10;
int f1(a) {
return(a*b);
}
main() {
printf("%d", f1(5));
}
#include<stdio.h>
#include<conio.h>
main()
{
int a=10, b=20;
clrscr();
printf("Before swapping a=%d b=%d",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("nAfter swapping a=%d b=%d",a,b);
getch();
}
#include <stdio.h>
union School {
int age, rollNo;
double marks;
};
void solve() {
union School sc;
sc.age = 19;
sc.rollNo = 82;
sc.marks = 19.04;
printf("%d", (int)sizeof(sc));
}
int main() {
solve();
return 0;
}
#include <stdio.h>
struct School {
int age, rollNo;
};
void solve() {
struct School sc;
sc.age = 19;
sc.rollNo = 82;
printf("%d %d", sc.age, sc.rollNo);
}
int main() {
solve();
return 0;
}
int main() {
int sum = 2 + 4 / 2 + 6 * 2;
printf("%d", sum);
return 0;
}
int (*ptr)[10];
#include <stdio.h>
void change(int,int);
int main()
{
int a=10,b=20;
change(a,b); //calling a function by passing the values of variables.
printf("Value of a is: %d",a);
printf("\n");
printf("Value of b is: %d",b);
return 0;
}
void change(int x,int y)
{
x=13;
y=17;
}
Explanation : The function "change" will change the value of x and y only within its own scope, so a and is unaffected.
#include <stdio.h>
int main()
{
char c[] = "GATE2011";
char *p = c;
printf("%s", p + p[3] -p[1]);
return 0;
}
Explanation : char c[ ] = "GATE2011";since char *p =c it means p represents to the base address of string “GATE2011” SO p[3] is 'E' and p[1] is 'A'. Value of Sub expression p[3] – p[1] = ASCII value of ‘E’ – ASCII value of ‘A’ = 4. So the expression p + p[3] – p[1] becomes ( p + 4) And (p+4) represent to base address of string “2011” printf(“%s”, p + p[3] – p[1]) ; So it will print 2011
int main() {
int a = 5, b = 6, c;
c = a++ + ++b;
printf("%d %d %d", a, b, c);
return 0;
}
char inchar = 'A';
switch (inchar)
{
case 'A' :
printf ("choice A \n") ;
case 'B' :
printf ("choice B ") ;
case 'C' :
case 'D' :
case 'E' :
default:
printf ("No Choice") ;
}
strcpy(str1, str2);