Program 1: Write a program to print
“Hello World”
CODE:
#include <stdio.h>
#include <conio.h>
void main()
clrscr();
printf("Hello, World");
getch();
}
Output:
Program 2: Write a program to print sum
of two numbers.
CODE:
#include <stdio.h>
#include <conio.h>
int main()
int num1, num2, x, y;
clrscr();
x = 20;
y = 10;
gotoxy(x, y);
printf("Enter first no.: ");
scanf("%d", &num1);
gotoxy(x, ++y);
printf("Enter second no.: ");
scanf("%d", &num2);
gotoxy(x, ++y);
printf("Sum of the two no.: %d", num1 + num2);
getch();
return 0;
}
OUTPUT:
Program 3: Write a program to find
maximum of two numbers.
CODE:
#include <stdio.h>
#include <conio.h>
void main ()
int num_1, num_2;
clrscr();
printf("Enter the no. to compare with space in between them: ");
scanf("%d %d", &num_1, &num_2);
if (num_1 > num_2)
printf("Maximum no.: %d", num_1);
else if(num_1 < num_2)
printf("Maximum no.: %d", num_2);
else
printf("Both the no. are same");
getch();
}
OUTPUT:
Program 4: Write a program that accept
the temperature in centigrade and
converts into Fahrenheit using the formula
c = (f – 32 ) * 5 / 9
CODE:
#include <stdio.h>
#include <conio.h>
void main()
float fahrenheit, centigrade;
clrscr();
printf("Plz enter the temprature in centigrade: ");
scanf("%f", ¢igrade);
fahrenheit = centigrade * 9 / 5 + 32;
printf("Temprature in fahrenheit: %f", fahrenheit);
getch();
}
OUTPUT:
Program 5: Write a program to find the
greatest of three numbers
CODE:
#include <stdio.h>
#include <conio.h>
void main()
int A,B,C;
clrscr();
printf("Plz enter three no. A,B and C in series: ");
scanf("%d %d %d", &A, &B, &C);
if(A > B && A > C)
printf("The greatest no. is A: %d",A);
else if(B > A && B > C)
printf("The greatest no. is B: %d",B);
else if(C > A && C > B)
printf("The greatest no. is C: %d",C);
else if(A == B && A == C)
printf("All three no. are equal.");
else if(A == B && B > C)
printf("A and B are equal and greater than C");
else if(A == C && A > B)
printf("A and C are equal and greater than B");
else
printf("B and C are equal and grater than A");
getch();
}
OUTPUT:
Program 6: Write a program that
calculates the simple interest. The
principal amount, Rate of interest and
time are entered through the keyboard.
CODE:
#include <stdio.h>
#include <conio.h>
void main()
float principle, roi, time, si;
clrscr();
printf("Please enter the principle ammount: ");
scanf("%f", &principle);
printf("Please enter the Rate Of Intrest: ");
scanf("%f", &roi);
printf("Please enter the Time in years: ");
scanf("%f", &time);
si = principle * roi * time;
printf("Simple intrest = %.2f", si / 100);
getch();
}
OUTPUT: