0% found this document useful (0 votes)
13 views2 pages

C Language Intro

Uploaded by

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

C Language Intro

Uploaded by

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

Introduction to C Language:

Variables and constants:


Data stores for storing values of different data
types i.e. integers(int), float, string(str),
character(char)

e.g. of data types:


integers: contains whole numbers e.g. 1,-145,200 etc.
float: contains decimal values e.g. 1.0,-145.4 etc.
character: contains single characters e.g. "@", "l", "1" etc.
string: contains a combination of characters e.g.
"abc", "I love Pakistan", "FIC Minhas" etc.

Input/output:
> for input: scanf("format specifier", &location)
e.g. scanf("%i",&num)

> for output: printf("format specifier",variable name)


e.g. printf("%f",name)

Declaration(Explicit):
> Format:
datatype variable name, variable name1;
e.g. int num1,num2,num3;
float average;

Selection/Conditional Statements:
> Syntax:
if(condition){
code;}

e.g. if(age > 18){


printf("Adult");}

if(condition){
code;}
else{
code;}

e.g. if(age > 18){


printf("Adult");}
else{
printf("Child");}

if(condition1){
code;}
elseif (condition2){
code;}
elseif(condition3){
code;}
.
.
.
.
.
.
else{
code;}

e.g.
if(age > 18){
printf("Adult");}
elseif(age < 18){
printf("Child");}
elseif(age == 18){
printf("Exactly 18");}
else{
printf("Invalid input");}

You might also like