HTML Tutorial || Networking Assignment || Computer Full Forms || Ms-Office Shortcut Keys || Ms-Office Notes || Number System Notes || Internet Assignment
JavaScript Tutorial || CSS Tutorial || Operating System Notes || History of Computer Assignment || Netwoking Notes || Computer Fundamentals Notes

C Program to Enter Basic Salary and Calculate Gross Salary of an Employee Using If Else ?


Q:- Write a  C Program to Enter Basic Salary and Calculate Gross Salary of an
       Employee Using If Else ?
      Input
        #include<stdio.h>
        #include<conio.h>
        int main()
   {
float basic,gross,da,hra;
printf(“Enter Basic Salary of an Employee =”);
scanf(“%f”,&basic);
if(basic <=10000)
{
da = basic * 0.8;
hra = basic * 0.2;
}
else if(basic <=20000)
{
da = basic * 0.9;
hra = basic * 0.25;
}
else
{
da = basic * 0.95;
hra = basic * 0.3;
}
gross = basic + hra + da;
printf(“Gross Salary of an Employee =%.2f\n”,gross);
getch();
    }


Output

Enter Basic Salary of an Employee = 22000
Gross Salary of an Employee = 49500.00

C Program to Input Marks of Five Subjects and Find Percentage and Grade Using If Else ?


Q:- Write a C Program to Input Marks of Five Subjects and Find Percentage and
       Grade Using If Else ?
Percentage >=90% : Grade A
Percentage >=80% : Grade B
Percentage >=70% : Grade C
Percentage >=60% : Grade D
Percentage >=40% : Grade E
Percentage <40%  : Grade F
       Input
         #include<stdio.h>
         #include<conio.h>
         int main()
   {
int phy,che,math,eng,comp;
float per;
printf(“Enter Five Subjects Marks =”);
scanf(“%d%d%d%d%d”,&phy,&che,&math,&eng,&comp);
per = (phy+che+math+eng+comp)/5.0;
printf(“Percentage = %.2f\n”,per);
if(per >= 90)
{
printf(“Grade A.”);
}
else if(per >= 80)
{
printf(“Grade B.”);
}
else if(per >= 70)
{
printf(“Grade C.”);
}
else if(per >= 60)
{
printf(“Grade D.”);
}
else if(per >= 40)
{
printf(“Grade E.”);
}
else if(per < 40)
{
printf(“Grade F.”);
}
else
{
printf(“Invalid Input!!!!!!!!!!”);
}
getch();
   }


Output

Enter Five Subjects Marks =
95
95
97
98
90
Percentage = 95.00
Grade A.

C program to Calculate Profit or Loss Using If Else ?


Q:- Write a C program to Calculate Profit or Loss Using If Else ?
      Input
        #include<stdio.h
        #include<conio.h>
        int main()
   {
float cp, sp, amt;
clrscr();
printf(“Enter Cost Price =”);
scanf(”%d”,&cp);
printf(“Enter Selling Price =”);
scanf(“%d”,&cp);
if(cp>sp)
{
amt=cp-sp;
printf(“Loss=%d”,amt);
}
else if(sp>cp)
{
amt=sp-cp;
printf(“Profit=%d”,amt);
}
else
{
printf(“No Profit No Loss.”);
}
getch();
    }


Output

Enter Cost Price = 1000
Enter Selling Price = 1500
Profit = 500

C program to Check Whether the Triangle is Equilateral, Isosceles and Scalene Triangle Using If Else ?


Q:- Write a C program to Check Whether the Triangle is Equilateral, Isosceles and
        Scalene Triangle Using If Else ?
       Input
         #include<stdio.h>
         #include<conio.h>
         int main()
   {
int s1,s2,s3;
clrscr();
printf(“Enter Three Sides of Triangle =”);
scanf(“%d%d%d”,&s1,&s2,&s3);
if(s1==s2 && s2==s3)
{
printf(“Equilateral Triangle.”);
}
else if(s1==s2 || s1==s3)
{
printf(“Isosceles Triangle.”);
}
else
{
printf(“Scalene Triangle.”);
}
getch();
   }


Output

Enter Three Sides of Triangle =
30
20
30
Isosceles Triangle.

C Program to Input all Sides of a Triangle and Check Whether Triangle is Valid or Not Using If Else ?


Q:- Write a C Program to Input all Sides of a Triangle and Check Whether Triangle is
       Valid or Not Using If Else ?
       Input
         #include<stdio.h>
         #include<conio.h>
         int main()
   {
int s1,s2,s3;
clrscr();
printf(“Enter Three Sides of Triangle =”);
scanf(“%d%d%d”,&s1,&s2,&s3);
if((s1+s2)>s3)
{
printf(“Triangle is Valid.”);
}
else if((s2+s3)>s1)
{
printf(“Triangle is Valid.”);
}
else if((s1+s3)>s2)
{
printf(“Triangle is Valid.”);
}
else
{
printf(“Triangle is not Valid.”);
}
getch();
   }


Output

Enter Three Sides of Triangle =
7
4
10
Triangle is Valid.