#include<stdio.h>
int mai
#include<stdio.h>
int mai
Practice Control Instructions –
#include<stdio.h>
int main() {
int i;
for(;scanf("%d", &i);printf("%d
", i));
return 0;
}
#include<stdio.h>
int mai
Practice Control Instructions –
#include<stdio.h>
int main() {
int i;
for(;scanf("%d", &i);printf("%d
", i));
return 0;
}
#include <stdio.h>
int fu
Practice Functions –
#include <stdio.h>
int fun(int);
int i;
int main(){
int j;
for(;;){
if(j=fun(i)){
printf("j=%d
",j);
}
else{
break;
}
}
return 0;
}
int fun(int x){
static int a=2;
a--;
return (a-x);
}
#include<stdio.h>
int ma
Practice Command Line Arguments –
#include<stdio.h>
int main(int argc, char **argv) {
printf("%d
", argv[argc]);
return 0;
}
#include <stdio.h>
#defin
Practice C Preprocessor –
#include <stdio.h>
#define SQR(x)(x*x)
int main() {
int a, b=3;
a = SQR(b+2);
printf("%d
", a);
return 0;
}
#include<stdio.h>
#defin
Practice C Preprocessor –
#include<stdio.h>
#define MAN(x, y) ((x)>(y)) ? (x):(y);
int main() {
int i=10, j=5, k=0;
k = MAN(++i, j++);
printf("%d, %d, %d
", i, j, k);
return 0;
}
#include <stdio.h>
#defi
Practice C Preprocessor –
#include <stdio.h>
#define SWAP(a, b, c) c t; t=a, a=b, b=t;
int main() {
int x=10, y=20;
SWAP(x, y, int);
printf("%d %d
", x, y);
return 0;
}
#include<stdio.h>
int mai
Practice Bitwise Operators –
#include<stdio.h>
int main() {
int x, y, z;
x=y=z=1;
z = ++x || ++y && ++z;
printf("x=%d, y=%d, z=%d
", x, y, z);
return 0;
}
#include <stdio.h>
int mai
Practice Library Functions –
#include <stdio.h>
int main() {
int a,b;
printf("enter values of a and b");
scanf("%d
,,%d",&a,&b);//a=4, b=5
printf("a=%d b=%d
",a,b);
return 0;
}
#include<stdio.h>
#include
Practice Functions –
#include<stdio.h>
#include<stdarg.h>
void display(char *s, ...);
void show(char *t, ...);
int main() {
display("Hello", 4, 12, 13, 14, 44);
return 0;
}
void display(char *s, ...) {
show(s, ...);
}
void show(char *t, ...) {
int a;
va_list ptr;
va_start(ptr, s);
a = va_arg(ptr, int);
printf("%f", a);
}
#include <stdio.h>
#includ
Practice Functions –
#include <stdio.h>
#include <stdarg.h>
void fun(int n, ...);
int main() {
fun(2, 12, 13, 14);
return 0;
}
void fun(int n, ...) {
va_list p;
va_start(p, n);
n= va_arg(p, int);
printf("%d", n);
}
#include <stdio.h>
#includ
Practice Functions –
#include <stdio.h>
#include <stdarg.h>
void fun(char *msg, ...);
int main() {
fun("Hello", 1, 4, 7, 11);
return 0;
}
void fun(char *msg,...) {
int num;
va_list ptr;
va_start(ptr, msg);
num = va_arg(ptr, int);
num = va_arg(ptr, int);
printf("%d", num);
}
#include <stdio.h>
#includ
Practice Functions –
#include <stdio.h>
#include <stdarg.h>
void fun(char *msg, ...);
int main() {
fun("Hello", 1, 4, 7, 11);
return 0;
}
void fun(char *msg,...) {
int num;
va_list ptr;
va_start(ptr, msg);
num = va_arg(ptr, int);
num = va_arg(ptr, int);
printf("%d", num);
}
# include <stdio.h>
int ma
Practice Control Instructions –
# include <stdio.h>
int main()
{
int n = 0;
for (n=0; n<20; n++)
{
switch(n)
{
case 0:
n += 5;
case 1:
n += 2;
case 5:
n += 5;
default:
n += 4;
break;
}
printf("%d ", n);
}
return 0;
}
#include <stdio.h>
int mai
Practice Control Instructions –
#include <stdio.h>
int main()
{
int i = 3;
switch (i)
{
case 0+1: printf("Crack");
break;
case 1+2: printf("Exams");
break;
default: printf("CrackExams");
}
return 0;
}
#include <stdio.h>
int mai
Practice Declarations and Initializations –
#include <stdio.h>
int main(){
float a=12.25, b=13.65;
if(a=b)
printf("a and b are equal");
else
printf("a and b are not equal");
return 0;
}