You are on page 1of 10

//TO CHOOSE THE SUBJECT OF STUDY - USE OF SWITCH/CASE CONTROL

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int choice;
printf("SUBJECT - CODE \n""Maths - 1 \n""Physics - 2 \n""Chemistry - 3 \n");
printf("Biology - 4 \n""History - 5 \n""Literature- 6 \n");
printf("Enter the subject you want to study ");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("You have chosen Maths");
break;
case 2:
printf("You have chosen Physics");
break;
case 3:
printf("You have chosen Chemistry");
break;
case 4:
printf("You have chosen Biology");
break;
case 5:
printf("You have chosen History");
break;
case 6:
printf("You have chosen Literature ");
break;
default:
printf("You are too clever to study here!");
}
getch();
}
//CONTINUOUS OPERATION - USE OF WHILE LOOP

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
//int i;
char ch='y';
int a;
int b;
int c;
//for(i=0;i<10;i++)
while(ch=='y')
{
b=2;
printf("Enter a number A = ");
scanf(" %d",&a);
c=a%b;
if(c==0)
{
printf("Entered number is even \n");
}
else
{
printf("Entered number is odd \n");
}
printf(" Do you want to continue.....(y/n)");
scanf(" %c",&ch);
}
getch();
}
//TO ADD TWO LONG INTEGERS

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
long int a;
long int b;
long int c;
a=1111111;
b=111111111;
c=a+b;
printf("the sum of a&b is %ld",c);
getch();
}
//TO PRINT A STATEMENT

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Greetings");
getch();
}
//TO PRINT ONE TO TEN - USE OF FOR LOOP

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i;
for(i=0;i<=10;i++)
{
printf(" %d \n\n",i);
getch();
}
}
//TO ADD TWO LARGE NUMBERS - USE OF LONG INT

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
long int a;
long int b;
long int c;
printf("Enter the value of large number A ");
scanf(" %ld",&a);
printf("Enter the value of large number B ");
scanf(" %ld",&b);
c=a+b;
printf("the sum of a&b is %ld",c);
getch();
}
//TO CHECK THE GREATER OF TWO GIVEN NUMBERS - USE OF IF/ELSE CONTROL

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a;
int b;
printf("Enter the value of A ");
scanf(" %d",&a);
printf("Enter the value of B ");
scanf(" %d",&b);
if(a<=b)
{
printf("A is smaller than B");
}
else
{
printf("B is smaller than A");
}
getch();
}
//TO EVALUATE THE GIVEN NUMBER AS ODD OR EVEN - USE OF IF/ELSE CONTROL

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a;
int b;
b=2;
int c;
printf("Enter the value of the number to be evaluated => ");
scanf(" %d",&a);
c=a%b;
if(c==0)
{
printf("The number submitted for evaluation is an even number ");
}
else
{
printf("The number submitted for evaluation is an odd number ");
}
getch();
}
//TO DO CONTINUOUS OPERATION - USE OF WHILE LOOP

#include<stdio.h>
#include<conio.h>
void main()
{
char ch='y';
int a;
int b;
int c;
do
{
clrscr();
printf("Enter the value of A =");
scanf(" %d",&a);
printf("Enter the value of B =");
scanf(" %d",&b);
c=a+b;
printf("The sum of the given values = %d \n\n",c);
printf("Do you want to continue.....(y/n) \n");
scanf(" %c",&ch);
getch();
}
while(ch=='y');
}
//TO ADD TWO GIVEN NUMBERS - USE OF SCAN STATEMENT

#include<stdio.h>
#include<conio.h>

void main()
{
clrscr();
int a;
int b;
int c;
printf("Enter the value of A ");
scanf(" %d",&a);
printf("Enter the value of B ");
scanf(" %d",&b);
c=a+b;
printf("The sum of A and B = %d",c);
getch();
}

You might also like