- Three numbers are input through keyboard.Write a program to find out the maximum and minimum of those 3 numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
printf("Enter value of a?\n");
scanf("%d",&a);
printf("Enter value of b?\n");
scanf("%d",&b);
printf("Enter value of c?\n");
scanf("%d",&c);
if(a>b&&a>c)
printf("\n Max a");
if(b>a&&b>c)
printf("\n Max b");
if(c>a&&c>b)
printf("\n Max c");
if(a<b&&a<c)
printf("\n\n Min a");
if(b<a&&b<c)
printf("\n\n Min b");
if(c<a&&c<b)
printf("\n\n Min c");
getch();
}
- Take a year as input and determine whether it is leap year.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int year;
printf("Enter a year to check for a leap year:");
scanf("%d",&year);
if((year%4==0 && year%100!=0)||(year%400==0))
{
printf("The entered year is a leap year.");
}
else
{
printf("The entered year is not a leap year.");
}
getch();
} - If cost price and selling price of an item is input through the keyboard, write a program to determine whether the seller has made profit or incurred loss.Also determine how much profit he made or loss he incurred.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x,y,sum;
printf("Enter cost price x?\n");
scanf("%d",&x);
printf("Enter selling price y?\n");
scanf("%d",&y);
if(x<y)
{
printf("The seller has made profit");
sum=y-x;
printf("\nThe profit is:%d",sum);
}
else
{
printf("The seller has incurred loss");
sum=x-y;
printf("\nThe loss is:%d",sum);
}
getch();
} - Any integer is input through keyboard. Write a program to find out whether it is an odd number or even number.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int num;
printf("Enter a num:");
scanf("%d",&num);
if(num%2==0)
printf("The occured number is even.");
else
printf("The occured number is odd.");
getch();
} - A 5 digit number is entered through the keyboard. Write a program to obtain the reverse number and to determine whether the original numbers are equal or not.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
long int num,num1,rem,numb=0;
printf("Enter the 5 digit number ?\n");
scanf("%ld",&num);
rem=num%10;
numb=numb+(10000*rem);
num1=num/10;
rem=num1%10;
numb=numb+(1000*rem);
num1=num1/10;
rem=num1%10;
numb=numb+(100*rem);
num1=num1/10;
rem=num1%10;
numb=numb+(10*rem);
num1=num1/10;
numb=numb+num1;
printf("\nThe reverse number of this number is:%ld",numb);
numb;
if(numb==num)
printf("\n\nThe numbers are equal");
else
printf("\n\nThe numbers are not equal");
getch();
} - Aust grading policy is:
- 80% marks or above is A+
- 75% to 79% marks is A
- 70% to 74% marks is A-
- 65% to 69% marks is B+
- 60% to 64% marks is B
- 55% to 59% marks is B-
- 50% to 54% marks is C+
- 45% to 49% marks is C
- 40% to 44% marks is D
- Below 40% is F
Write aprogram which will take an input from user and calculate the grade of a student according to Aust grading policy based on that input.#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x;
printf("Enter a mark:");
scanf("%d",&x);
if(x>=80)
printf("The grade is:A+");
else if(x>=75&&x<=79)
printf("The grade is:A");
else if(x>=70&&x<=74)
printf("The grade is:A-");
else if(x>=65&&x<=69)
printf("The grade is:B+");
else if(x>=60&&x<=64)
printf("The grade is:B");
else if(x>=55&&x<=59)
printf("The grade is:B-");
else if(x>=50&&x<=54)
printf("The grade is:c+");
else if(x>=45&&x<=49)
printf("The grade is:c");
else if(x>=40&&x<=44)
printf("The grade is:c");
else if(x<40)
printf("The grade is:F");
getch();}- A certain grade of steel is graded according to the following conditions:
1.Hardness must be greater than 602.Certain content must be less than 0.73.Tensile strength must be greater than 5000
The grades are as follow:
Grade is 10 if all three conditions are metGrade is 9 if condition 1 and 2 are metGrade is 8 if condition 2 and 3 are metGrade is 7 if condition 1 and 3 are metGrade is 6 if only one condition is metGrade is 5 if one of the conditions are metWrite a program which will require the user give values of hardness, carbon content and tensile strength of the steel under consideration and output the grade of the steel.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x,z;
float y;
printf("Enter the value of hardness?\n");
scanf("%d",&x);
printf("carbon content?\n");
scanf("%f",&y);
printf("Enter tensile strength?\n");
scanf("%d",&z);
if (x>60&&y<0.7&&z>5000)
printf("Grade is 10");
else if(x>60&&y<0.7)
printf("Grade is 9");
else if(y<0.7&&z>5000)
printf("Grade is 8");
else if(x>60&&z>5000)
printf("Grade is 7");
else if(x>60||y<0.7||z>5000)
printf("Grade is 6");
else
printf("Grade is 5");
getch();}
- A certain grade of steel is graded according to the following conditions:
No comments:
Post a Comment