Professional Documents
Culture Documents
CC1 (C Language)
CC1 (C Language)
CC1 (C Language)
Archana Kumari
Semester-I
CC1
Contact No. 9431389410
archanamcrranchi@gmail.com
Date : 15/10/2023
Introduction to C
• C programming is a general-purpose,
procedural, imperative computer programming
language developed in 1972 by Dennis M.
Ritchie at the Bell Telephone Laboratories to
develop the UNIX operating system.
…….
• C was invented to write an operating system called UNIX.
• C is a successor of B language which was introduced around the early
1970s.
• The language was formalized in 1988 by the American National
Standard Institute (ANSI).
• The UNIX OS was totally written in C.
• Today C is the most widely used and popular System Programming
Language.
• Today's most popular Linux OS and RDBMS MySQL have been written
in C.
Write a program in c to print a message ” Welcome students in course
IT”
#include <stdio.h>
#include<conio.h>
void main()
{
printf(“Welcome students in course IT");
getch();
}
•Save- File->save
•Compile –Alt+C
•Run – Alt+R
•Output- welcome students in course IT
• #include <stdio.h> includes the standard inputoutput library
functions.
• The printf() function is defined in stdio.h .
• #include <conio.h> includes the console inputoutput library
functions.
• The getch() function is defined in conio.h file.
• void main()
• Compiler start execution from Main() in C language.
• The void keyword specifies that it returns no value.
• printf() The printf() function is used to print data on the console.
• getch() The getch() function asks for a single character. Until you
press any key, it blocks the screen.
Data Type
Type Storage size Value range
Increment
Pre Post
++i; i++;
Increment and decrement operator
decrement
Pre Post
--i; i--;
•&
AND OR NOT
• 4&5=4 00 0 000 10
010 011
• 100 100 101
01
111 111
• 101
• 100
• 4|5=5
• 100
• 101
• 101
Control Statements
• if-else
• Switch- Case
• do-while loop
• while loop
• for loop
• Goto
• break
• continue
•
if statement
• It is bi-branching decision making statement
• The if-else statement is used to execute the code if condition is true
or false.
• Syntax:
if (expression)
{code to be executed if condition is true}
else
{code to be executed if condition is false}
ways to use if statement in Clanguage
• If statement
• If-else statement
• If else-if ladder
• Nested if
Write a program in c to store a number from
user and check it is positive or negative.
• #include <stdio.h>
• int main()
• { int n;
• printf("enter no");
• scanf("%d",&n);
• if(n>=0) printf("it is positive");
• else printf("it is negative");
• return 0;}
Draw a flowchart to check whether a number
n is negative or positive .
Input number n
True False
Is n>=0
Print”positive Print”negative
stop
For loop
• It is good if number of iteration is known by the user.
• Syntax:-
for(initialization;condition;incr/decr)
{code to be executed
}
•
To print 1 to 100
• int main()
• { int i;
• for(i=1;i<=100;i++)
• printf("%d ",i);
• return 0;}
Draw a flowchart To print 1-100(while…loop)(for….loop)
i=1
False(i=101)
Is i<=100
True
Print i
i++
stop