0% found this document useful (0 votes)
268 views5 pages

T1-Cs101 - Introduction To Computing 1 2014

This document contains examples of simple if statements in C programming. The first example displays a message if a user-input number is less than 20. The second finds the largest of three user-input numbers. The third checks if a number is single-digit. The fourth checks if a character is a vowel. Each example includes the code, input, and output.

Uploaded by

skyyyeisthebest
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
268 views5 pages

T1-Cs101 - Introduction To Computing 1 2014

This document contains examples of simple if statements in C programming. The first example displays a message if a user-input number is less than 20. The second finds the largest of three user-input numbers. The third checks if a number is single-digit. The fourth checks if a character is a vowel. Each example includes the code, input, and output.

Uploaded by

skyyyeisthebest
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

T1-CS101 INTRODUCTION TO COMPUTING 1 2014

B. SIMPLE IF
1. A Program that will run if the value is lesser than 20
CODE
#include<stdio.h>//header
#include<conio.h>//header
Main()//main function
{//terminal
Int a;//variable
Clrscr();//clear screen
Printf(input the value:__);//displays a string
Scanf(%d,&a);//scan formatted
If (a<20)//sequence statement
{//terminal
Printf(Number %d is less than 5,a);//displays a string
}//terminal
Getch();//support the conio

OUTPUT
Input the value: 10
Number 10 is less than 20

Shermaine May F. Apigo

T1-CS101 INTRODUCTION TO COMPUTING 1 2014

2. Program to Read Three Numbers and Print the Biggest Of Given Three Numbers
CODE
# include <stdio.h>//header
# include <conio.h>//header
main( )//main function
{//terminal
int a,b,c,big=0;//variable
clrscr( );//clear screen
printf(ENTER VALUE FOR A:);//displays a string
scanf(%d,&a);//scan formatted
printf(ENTER VALUE FOR B:);//displays a string
scanf(%d,&b);//scan formatted
print(ENTER VALUE FOR C:);//displays a string
scanf(%d,&c);//scan formatted
if (a>big)//sequence statement
big=a ;
if(b>big)//sequence statements
big=b;
if (c>big)//sequence statements
big=c;
printf (BIGGEST OF ABOVE GIVEN THREE NUMBER IS %d,big)//displays a
string
getch( );//sipport conio
Shermaine May F. Apigo

T1-CS101 INTRODUCTION TO COMPUTING 1 2014

}//terminal
OUTPUT
ENTER VALUE FOR A: 2
ENTER VALUE FOR B: 4
ENTER VALUE FOR C: 6
BIGGEST OF ABOVE GIVEN THREE NUMBER IS: 6

Shermaine May F. Apigo

T1-CS101 INTRODUCTION TO COMPUTING 1 2014

3. To check the enter number is single digit or not


CODE
#include<stdio.h>//header
#include<conio.h>//header
main()//main function
{//terminal
int n;//variable
clrscr();//clear screen
printf(Enter a number:);//displays a string
scanf(%d,&n);//scan formatted
if(n<=9)//sequence statements
printf(Single digit);//displays a string
if(n>9)//sequence statements
printf(Not single digit);//displays a string
getch();//support a conio
}//terminal

OUTPUT
Enter a number:5
Single digit
OUTPUT 2
Shermaine May F. Apigo

T1-CS101 INTRODUCTION TO COMPUTING 1 2014

Enter a number:12
Not single digit
4. To check whether the character is vowel
CODE
#include<stdio.h>//header
#include<conio.h>//header
main()//main function
{//terminal
char x;//variable for character
clrscr();//clear screen
printf(Enter a letter:);//displays a string
scanf(%c,&x);//scan formatted
if(x==a || x==A || x==e || x==E || x==i || x==I
|| x==o || x==O || x==u || x==U)//sequence statement
printf(It is Vowel);//displays string
getch();//support a conio
}//terminal

OUTPUT
Enter a letter: u
It is Vowel

Shermaine May F. Apigo

You might also like