0% found this document useful (0 votes)
23 views22 pages

CC1 (C Language)

Uploaded by

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

CC1 (C Language)

Uploaded by

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

Dr.

Archana Kumari

Semester-I
CC1
Contact No. 9431389410

[email protected]
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

char 1 byte -128 to 127 or 0 to 255

unsigned char 1 byte 0 to 255

signed char 1 byte -128 to 127

int 2 bytes -32768 to +32767

unsigned int 2 bytes 0 to 65535

Short 2 bytes -32768 to 32767

Unsigned short 2 bytes 0 to 65535

long 4 bytes -231 to +231-1

Unsigned long 4 bytes 0 to 232-1


Type Storage size Value range

float 4 bytes 1.2E-38 to 3.4E+38


Double 8 bytes 2.3E-308 to 1.7E+308
OPERATORS
• Arithmetic Operators + -*/ %
• Relational Operators > , >= ,<,<=, ==, !=
• Shift Operators >>, <<
• Logical Operators &&(AND),||(OR), !(NOT)
• Bitwise Operators &(AND),|(OR), !(NOT)
• Ternary or Conditional Operators
• Assignment Operator =,+=,-=,*=
• Misc Operator

bitwise
• 5&4=4
• 101
• 100
• ------
• 100
• 5|4=5
• 101
• 100
• ------
• 101
•5 Q R
• 5%2=2 1
• 2%2=1 0
• Binary of 5=101
• 4%2=2 0
• 2%2=1 0
• 4= (100)2
Assignment operator
• a=5;
• a+=5;
• A=a+5;
• A*=5;
• A=A*5;
Increment and decrement operator

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

You might also like