c if programs

      Comments Off on c if programs

c if programs

c if programs

c if programs sample code of many programs to demonstrate how to use if condition in C Programming Language. Refer following program to learn how to use if condition in c language. I highly recommend to refer my previous article of c fundamental programs before you refer this programs.

Have you check, C Loop Tutorial?

C Language Program 1

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in/  
//c program demonstrate use of if condition to find result of student weater pass or fail

#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	float m1,m2,m3,m4,m5,m6,m7,result,total,percentage;

	printf("Enter Marks of All Subject (7 Subject) : \n");
	scanf("%f %f %f %f %f %f %f",&m1,&m2,&m3,&m4,&m5,&m6,&m7);

	total=m1+m2+m3+m4+m5+m6+m7;
	percentage=total/7.0;

	if(m1>=36 && m2>=36 && m3>=36 && m4>=36 && m5>=36 && m6>=36 && m7>=36)
	{
		printf("\nTotal   \t : %.2f",total);
		printf("\nResult\t\t : Pass");
		printf("\nPercentage \t : %.2f",percentage);
	}
	else
		printf("\nResult\t : Fail");

getch();
}

 

C Language Program 2

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in/  
// c program to demonstrate use of if condition give dividend to user if salary is more than 10000

#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	float profit,dividend;

	printf("Enter Basic Salary :");
	scanf("%f",&profit);

	printf("====================================");

	if(profit>10000)
		printf("\nDividend is           :%.2f",profit*0.05);
	else
		printf("\nDividend is not allow");

	getch();
}

 

C Language Program 3

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in/  
//c program demonstrate use of if condition to find result of student weater pass or fail and calculate grade

#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	float m1,m2,m3,m4,m5,m6,m7,result,total,percentage;

	printf("Enter Marks of All Subject (7 Subject) : \n");
	scanf("%f %f %f %f %f %f %f",&m1,&m2,&m3,&m4,&m5,&m6,&m7);

	total=m1+m2+m3+m4+m5+m6+m7;
	percentage=total/7.0;

	if(m1>=36 && m2>=36 && m3>=36 && m4>=36 && m5>=36 && m6>=36 && m7>=36)
	{
		printf("\nTotal   \t : %.2f",total);
		printf("\nResult\t\t : Pass");
		printf("\nPercentage \t : %.2f",percentage);

		if(percentage>=70)
			printf("\nGrade is         : A");
		else
		{
			if(percentage>=60)
				printf("\nGrade is         : B");
			else
			{
				if(percentage>=50)
					printf("\nGrade is         : C");
				else
					printf("\nGrade is         : Pass");
			}
		}
	}
	else
		printf("\nResult\t : Fail");

getch();
}

 

C Language Program 4

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in/  
// c program to find out number is positive, negative or zero 
#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	int number;

	printf("Enter Number (Positive, Negative or Zero) :");
	scanf("%d",&number);

	printf("===========================================\n");

	if(number==0)
		printf("Number is : 0");
	else
	{
		if(number>0)
			printf("Number is : Positive");
		else
			printf("Number is : Negative");
	}

	getch();
}

 

 

C Language All Program Download

Download[sociallocker][/sociallocker]