Posts

Showing posts from April 23, 2020

Chapter 2 Program 12

Also visit our YouTube Channel Tech Eos     VISIT CHANNEL /*     12. Write a program to implement calculator using switch case.    */ #include<stdio.h> #include<conio.h> void main() { int number1 , number2 , choice; clrscr(); do { printf("\n\nEnter 1 number value : "); scanf("%d" , &number1 ); printf("\nEnter 2 number value : "); scanf("%d" , &number2 ); printf("\n\n1. Sum"); printf("\n2. Substraction"); printf("\n3. Multiply"); printf("\n4. Division"); printf("\n\n0. Exit"); printf("\n\nEnter your choice  :  "); scanf("%d" , &choice ); switch( choice ) { case 1: printf("\n\nSum = %d " , number1+number2 ); break; case 2: printf("\n\nSubstraction = %d " , number1 ...

Chapter 2 Program 11

Also visit our YouTube Channel Tech Eos     VISIT CHANNEL /*  11. The ABC Insurance Company Ltd. Offers the following three    categories of car insurance policy to car owners: ~ Category A, here the basic premium is calculated as 2% of the car's value. ~ Category B, here the basic premium is calculated as 3% of the car's value. ~ Category C, here the basic premium is calculated as 5% of the car's value. */ #include<stdio.h> #include<conio.h> void main() { float car_price; char category; clrscr(); printf("\n\nEnter your car's price  :  "); scanf("%f" , &car_price ); printf("\n\nA. 2 percentage premium"); printf("\nB. 3 percentage premium"); printf("\nC. 5 percenteage premium"); flushall(); printf("\n\nEnter your category  :  "); scanf("%c" , &category ); if( category == 'A' ||...

Chapter 2 Program 10

Image
Also visit our YouTube Channel Tech Eos     VISIT CHANNEL /* 10. Write a program to calculate bill of a job work done as follows. Use if else statement. a) Rate of typing 3 Rs/page b) Printing of 1st copy 5Rs/pages & later every copy 3Rs/page. The user should enter the number of pages and print out copies    he/she wants. */ #include<stdio.h> #include<conio.h> void main() { int pages , copies ; int typing_cost=0; int printing_cost=0; int printing_cost2=0; clrscr(); printf("\nEnter total number of pages  : "); scanf("%d" , &pages); printf("\nEnter total number of copies : "); scanf("%d" , &copies); typing_cost = pages*3; printf("\n\nTyping cost is %d " ,  typing_cost ); if( copies == 1 ) { printing_cost = pages*5; printf("\n\nPrinting price of 1 copie is %d" , printi...

Chapter 2 Program 9

Image
Also visit our YouTube Channel Tech Eos     VISIT CHANNEL /* 9. Write a program to check whether the blood donor is eligible or not for donating blood. The conditions laid down are as under.  Use if statement. a) Age should be above 18 yrs but not more than 55 yrs. */ #include<stdio.h> #include<conio.h> void main() { int age ; clrscr(); printf("Enter your age  : "); scanf("%d" , &age ); if( age >=18 && age<=55 ) { printf("\n\nYour are eligible for donating blood"); } else { printf("\n\nYour are not eligible for donating blood"); } getch(); }

numbers from the user and print the greater number ( Chapter 2 Program 8)

Image
Also visit our YouTube Channel Tech Eos     VISIT CHANNEL /* 8. Take 2 numbers from the user and print the greater number (Number can be equal).                      */ #include<stdio.h> #include<conio.h> void main() { int number1 , number2 ; clrscr(); printf("\nEnter 1 number : "); scanf("%d" , &number1 ); printf("\nEnter 2 number : "); scanf("%d" , &number2 ); if( number1 == number2 ) { printf("\n\nBoth numbers are equal"); } else { if( number1 > number2 ) { printf("\n\nMaximum is %d" , number1 ); } else { printf("\n\nMaximum is %d" , number2 ); } } getch(); }

( Chapter 2 Program 7 )

Image
Also visit our YouTube Channel Tech Eos     VISIT CHANNEL /*    7. Take marks from the user and print grade accordingly ( >=75 marks - Distinction , <75 and >=60 marks - First , <60 and >=50 - Second , <50 and >=35 - Pass , <35 - Fail) using if ... else if... else statement and also by using logical operators).                */ #include<stdio.h> #include<conio.h> void main() { int marks ; clrscr(); printf("\nEnter your marks : "); scanf("%d" , &marks ); // Nested if if( marks >= 75 ) { printf("\n\nDistinction"); } else if( marks >= 60 && marks <75 ) { printf("\n\nFirst"); } else if( marks >=50 && marks < 60 ) { printf("\n\nSecond"); } else if( marks >= 35 && marks <50 ) { ...

Maximum from three ( Chapter 2 Program 6 )

Image
Also visit our YouTube Channel Tech Eos     VISIT CHANNEL /*   6. Write . */ #include<stdio.h> #include<conio.h> int func_maximum(int,int,int); void main() { int number1 , number2 , number3 ; clrscr(); printf("\nEnter 1 number value : "); scanf("%d" , &number1); printf("\nEnter 2 number value : "); scanf("%d" , &number2); printf("\nEnter 3 number value : "); scanf("%d" , &number3); printf("\n\nMaximum is %d " , func_maximum(number1,number2,number3)  ); getch(); } int func_maximum( int a , int b , int c ) { int max = 0; while( a>0 || b>0 || c>0 ) { a-- , b-- , c-- , max++; } return(max); }