C Programming
C Programming
#include<stdio.h>
#include<conio.h>
void main() {
clrscr();
printf("Hello World!");
getch();
Output
Hello World!
------------------------------------------------------------------------------------------
#include<conio.h>
void main() {
clrscr();
int a,b,sum;
scanf("%d",&b);
sum=a+b;
printf("\nSum = %d",sum);
getch();
Output
Sum = 15
------------------------------------------------------------------------------------------
#include<stdio.h>
#include<conio.h>
void main() {
clrscr();
int a,b,sub;
scanf("%d",&a);
scanf("%d",&b);
sub=a-b;
printf("\nSubtraction = %d",sub);
getch();
Output
Subtraction = -5
------------------------------------------------------------------------------------------
Program 4 (Multiplication)
<code>
#include<stdio.h>
#include<conio.h>
void main()
int a,b,mul;
clrscr();
scanf ("%d",&a);
scanf("%d",&b);
mul=(a*b);
printf("mul=%d",mull);
getch();
Output
mul=300
------------------------------------------------------------------------------------------
Program 5 (Devision)
<code>
#include<stdio.h>
#include<conio.h>
void main()
int a,b,div;
clrscr();
scanf("%d",& a);
scanf("%d",& b);
div=a/b;
printf("division=%d",div);
getch();
Output
division=2
------------------------------------------------------------------------------------------
Program 6 (Average of 3 Numbers)
<code>
#include<stdio.h>
#include<conio.h>
void main() {
int a,b,c;
float avg;
clrscr();
printf("a=");
scanf("%d",&a);
printf("b=");
scanf("%d",&b);
printf("c=");
scanf("%d",&c);
avg=(a+b+c/3);
printf("avg=%f",avg);
getch();
Output
a=5
b=10
c=15
avg=20.000000
------------------------------------------------------------------------------------------
Program 7 (All Arthamatics Program)
<code>
#include<stdio.h>
#include<conio.h>
void main(){
clrscr();
int a=25,b=5;
printf("\na+b = %d",a+b);
printf("\na-b = %d",a-b);
printf("\na*b = %d",a*b);
printf("\na/b = %d",a/b);
printf("\na%b = %d",a%b);
printf("\na+1 = %d",++a);
printf("\nb-1 = %d",--b);
getch();
Output
a+b = 30
a-b = 20
a*b = 125
a/b = 5
a%b = 0
a+1 = 26
b-1 = 4
------------------------------------------------------------------------------------------
Program 8 (Relational Operators)
<code>
#include<stdio.h>
#include<conio.h>
void main()
int a=24,b=7;
clrscr();
printf("a<b:%d\n",a<b);
printf("a>b:%d\n",a>b);
printf("a<=b:%d\n",a<=b);
printf("a>=b:%d\n",a>=b);
printf("a==b:%d\n",a==b);
printf("a!=b:%d\n",a!=b);
getch();
Output
a<b:0
a>b:1
a<=b:0
a>=b:1
a==b:0
a!=b:1
------------------------------------------------------------------------------------------
Program 9 (Assignment Operators)
<code>
#include<stdio.h>
#include<conio.h>
void main()
int a=10;
printf("Value of a is %d\n",a);
a+=10;
printf("Value of a is %d\n",a);
a-=10;
printf("Value of a is %d\n",a);
a*=10;
printf("Value of a is %d\n",a);
a/=10;
getch();
Output
Value of a is 10
Value of a is 20
Value of a is 10
Value of a is 100
------------------------------------------------------------------------------------------
#include<stdio.h>
#include<conio.h>
void main()
int i=0;
clrscr();
for (i=1;i<10;i++)
printf("hello world\n");
getch();
Output
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
------------------------------------------------------------------------------------------
Program 11 (While Loop)
<code>
#include<stdio.h>
#include<conio.h>
void main()
int i=2;
clrscr();
while (i<=10)
printf("hello word\n");
i++;
getch();
Output
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
------------------------------------------------------------------------------------------
#include<stdio.h>
#include<conio.h>
int main()
int i=10;
do
printf("%d",i);
i--;
while(i>=1);
getch();
return 0;
Output
10987654321
------------------------------------------------------------------------------------------
#include<stdio.h>
#include<conio.h>
int sum(int a, int b)
return a+b;
int main(){
clrscr();
getch();
return 0;
Output
Sum is 30
------------------------------------------------------------------------------------------
Program 14 (Switch)
<code>
#include<stdio.h>
#include<conio.h>
void main() {
int ch;
clrscr();
int i=2;
scanf("%d",&ch);
switch(ch)
case 1:
printf("Monday\n");
break;
case 2:
printf("Tuesday\n");
break;
case 3:
printf("Wednessday\n");
break;
case 4:
printf("Thursday\n");
break;
case 5:
printf("Friday");
break;
case 6:
printf("Saturday");
break;
case 7:
printf("Sunday");
deafult:
break;
i++;
getch();
Output
Friday
------------------------------------------------------------------------------------------