Programming with C – Input/Outputs & Decision Making-Lecture 2

Structure of C Program

# include < header file>  // # is pre-processor directive

 #define x  5  //symbolic constant

int a, b;   //global variable declaration

int fxn();  // function declaration

main() //main function


int i,j,k;     // local variable declaration

Input statements;


Output Statements;


Loader Loading...
EAD Logo Taking too long?

Reload Reload document
| Open Open in new tab


# include <stdio.h>

void main() {  char  name[20]; int rollno;

scanf(“%[  ABCDEFGHIJKLMN]”, name); /* The characters(as per case) given in scanf are valid character for input. Like space & other given character, if we give input GAGAN DEEP, the input taken upto GAGAN DEE, P terminate the string*/

printf(“%s ”, name); //whereas in output %s works for a full string


Your input may be of  : GAGAN DEEP

Output is GAGAN  DEE

(Only character other than the given character s can terminate the string.)


Example : WAP to find ASCII value of a character

#include <stdio.h>


void main()

{  char c;

printf(“Enter a character: “);

scanf(“%c”,&c); // Takes a character from user

printf(“ASCII value of %c = %d”,c,c);



Decision Making

—C program may require that a logical test be carried out at some particular point within the program. One of several possible actions will then be carried out, depending upon the outcome of the logical test. This is known as branching.

—There is also a special kind of branching, called selection, in which one group of statement is selected from several available groups.

—C conditional statement allow you to make decision, based upon the result of a condition.

—These statement are also known as decision making statement, conditional statement, branching statement  or  selection statements.

Previous Lecture : 

Published by

Gagan Deep

FOUNDER & DIRECTOR, ROZY COMPUTECH SERVICES, KUK, KURUKSHETRA (HARYANA), INDIA I am in the profession of teaching in Computer Science since 1996.  In 1996, established a professional setup “Rozy Computech Services” for providing Computer Education, computer hardware and software services. In this span of 21 years , in conjunction with Rozy’s, I also associated in Teaching with different Institutions like Assistant Professor in University College, Kurukshetra University, Kurukshetra, Guest Faculty in Directorate of Distance Education, Kurukshetra University, Visiting Faculty in University Institute of Engineering & Technology, Kurukshetra University and a Resource person in EDUSAT, Haryana. Besides, I am also serving as Guide and Mentor in various private educational institutions. Also written 7 books on computer science.

Leave a Reply

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