Simple if statement in C

Simple if Syntax

The form of an if statement is as follows:

Practice Programs

(i)	   
#include<stdio.h>
void main()
{
	system("color fc"); 
	// e = = light yellow = Output window background color
	//c = = Light red = Output window text color 
	int x = 5;
	
	if(x)
	printf("EngineersTutor.com")
}
(ii)
#include<stdio.h>
void main()
{
	system("color ec"); 
	// e = = light yellow = Output window background color
	//c = = Light red = Output window text color 
	
	int x = 5;
	
	if(x>10)
	printf("EngineersTutor.com");
}
(iii)
#include<stdio.h>
void main()
{
	system("color ec"); 
	// e = = light yellow = Output window background color
	//c = = Light red = Output window text color
	
	int x = 5;
	
	if(x == 10)
	printf("EngineersTutor.com");
}
(iv)
#include<stdio.h>
void main()
{
	system("color ec"); 
	// e = = light yellow = Output window background color
	//c = = Light red = Output window text color
	
	int x = 5, y = 10;
	
	if(x+y)
	printf("EngineersTutor.com");
}
(v)
#include<stdio.h>
void main()
{
	system("color ec"); 
	// e = = light yellow = Output window background color
	//c = = Light red = Output window text color
	
	int x = 5, y = 10;
	
	if( (x+y)>30 )
	printf("EngineersTutor.com");
}
(vi)
#include<stdio.h>

void main()
{
	system("color ec"); 
	// e = = light yellow = Output window background color
	//c = = Light red = Output window text color
	
	int x = 5, y = 10;
	
	if( (x+y)>30 )
	{
		printf("EngineersTutor.com");
		printf("Teach Easy");
	}
}
(vii)
#include<stdio.h>
void main()
{
	system("color ec"); 
	// e = = light yellow = Output window background color
	//c = = Light red = Output window text color
	
	int x = 5, y = 10;
	
	if( (x+y)<30 )
		printf("EngineersTutor.com\n");
		printf("Teach Easy\n");
	    printf("Albert\n");
	    printf("Stephen");
}
(viii) Testing for Leap year
#include<stdio.h>

void main()
{
	int year;
	printf("enter year \n");
	scanf("%d", &year);
	
	if((year%400==0)||((year%4==0)&&(year%100!=0)))
		printf("given year is leap year \n");	
	else
		printf("not leap year \n");
}

Program explanation

Gopal Krishna

Hey Engineers, welcome to the award-winning blog,Engineers Tutor. I'm Gopal Krishna. a professional engineer & blogger from Andhra Pradesh, India. Notes and Video Materials for Engineering in Electronics, Communications and Computer Science subjects are added. "A blog to support Electronics, Electrical communication and computer students".

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate »