C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
C यह
य
ह य
ह
computer language ह ह ह.
ह
ह
ह
ह
ह
आ
ह
. Hindi
आ
यह
ह यऔ
C/C++ programming ,आ
ह
ह
Hindi ह, C/C++
C/C++ programming language
आ
ह ह
. आ
य यह ह ह
य
C/C++
य
language ह
;ह
ह
, ह. आ
ह
आ औ
ह
ह आ
ह
. यह C/C++ programming language hindi tutorial यह
ऱ और
य ; आ
C/C++
औ
आ ह
य
ह
ह
ह ह
ह
य
य .
य
ह
ह. आ
हयआ
ह ह
C/C++
C/C++ य
य
computer language .
ह,
र ऱ
यय
य
ह ह आ
य ह
.
Compiler य ह ह
computer ह आ
ह ह
ह
ह आ
ह
ह
.
===Windows 1 . dev-c++ open 2.य
ऱ
software
.
ह
language
convert
compiler
software ह,
computer
ह ह.
ऱ === . (Start -> All Programs -> Dev-C++) "Tip of the Day" ह
य
आ
window य)
ह
. computer
र
Dev-C++
ह य tips
computer
ह
English
ह
computer ह
program
program
ह
(computer program)
य ह
.(
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
3.
File
(
File
ऊ
)
औ
New
आ
.
ह
यऔ
ह.
Source program
.
? 1#include 2 3int main() { 4 printf("Namaskar"); 5 6 scanf("%s"); 7 return 0; } 8 4.
menu :ऊ
program
Error आ 5. ह
य
य
spelling
य
Compile
.
menu
य. आ
Execute -> Run
Namaskar. य
==Ubuntu Linux 1.
य.
Execute ->Compile
window
output ह.
program
आ
ऱ == य
text editor (vim , gedit , emacs ...)
2.
.
आ
.
य.
औ
program
namaskar.c
ह.
ह
C program
.c
आ य ह. ? 1#include 2 3int main() { 4 printf("Namaskar"); 5 6 return 0; 7} 3.
terminal
ह . यह 4 command
औ cd command य
आ
य आ
य ह.
ह आ
य
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
१. ls : current
औ
२. cd .. : current
ह आ
३. cd <
.
.
>: current
४. pwd : current
full location
.
4 . यह औ Enter
gcc namaskar.c
compile ह
error ह आ ह
.
आ
य ह.
5 . Run ./a.out
आ
namaskar
य .औ आ
Run ह
य.
ह आ
.
आ
Hindi
C/C++ programming language tutorial ह program
.
ह
य
line ह
line ह
program
ह line
य ह
Namaskar
program औ program
औ
ह
औ
ह
ह points
य
हआ ह. C
printf
हआ आ य य
printf
हआ आ
ह.
.
program .
ह
program
Namaskar
ह ह screen
""
ह, य
screen
printf("Namaskar");
य lines 3 line
ह
ह ह.
? 1#include 2int main() { 3 printf("Namaskar"); scanf("%s"); 4 return 0; 5 } 6 आ ह ह C/C++ program आ
आ
ह.
औ output
ह program ऊ line
function
ह changes
आ . 2 line .
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
ह program ह
1.C
ह
main() {
run ह
ह
हऔ
line
ह
program
ह
ह main() {
ह. यह ह
ह
य
ह य ह
), ह function
use
ह. input
ह. ह
ह compiler
ह
ह
2 line execute ह
function
3. function
ह. program run ह हऔ }
run (execute )
function य method ह (ह यह function
2.printf
ह
यह य program
semicolon ह
यह function
ह
ह (;)
आ
य ह
ह
य
ह. semicolon command
.
य.
? 1#include 2int main() { 3 printf("Namaskar") scanf("%s"); 4 return 0; 5 } 6 आ program compile In function `int main()': error: expected `;' before "scanf" Execution terminated यह ह scanf ह ; आ
य
ऊ
य
ह
modify
topic
compile
ह variables
य
ह
error
ह ,
ऊ ; ह
variable use ?
ह. य
य.
य .
ह
य
ह
ह.
आ
program
.
औ , interest( य
आ
program )
calculation य
variables in C/C++ programming language Variable यह ह ह ह ह, ह. define
य
printf function
ह compile
program य ह
ह
ह
program
यह compile ह
compile
यह
.
ह.
यह ह
ह ह C/C++ program
ह ह.
ह
हय
ह variable define ह ह.
ह
ह
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
1 #include 2int main() { 3 int x; 4 x = 1; 5 x = 5; 6 7 scanf("%s"); return 1; 8} 9 program ह.
3 line add
ह
ह ह
ह program ह ह
यह
ह
printf
हह
ह
ह.
ह
x
variable define
integer य
य ह औ int यह
ह.
यह temp
int temp;
line
हआ ह int x;
line
यह variable
ह
यय
3 line
1. int main() {
आ
program
variable define
integer (
. 2. x = 1; variable x ह ह.
1
define ह
C/C++ program ह
य line
ह
ह
, ह x
5
variable define
ह .
Expression in C/C++ programming language Expression example य. ? 1 #include 2 3 int main() { 4 int price; int rate ; 5 int time; 6 7 price = 1000; 8 rate = 5; 9 time = 3; 10 11 int interest; 12 interest = price*rate*time/100; 13 14 scanf("%s"); return 1; 15} 16
य
.
ह ह. ह
line
ह x
)
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
17 ऊ
ह 3 variable: price, rate, time define
program य ह. ह
ह
*, / औ
value screen
150 आ ह print
ह
parameter
value print
interest
set
(multiplication) औ /
आ
interest variable
value 150 ह
ह
ह ह. printf paremeter ह
ह +, -,
) ह ह screen
.
यह ह.
हय
ह.
ह.
""
औ
यह printf function 2 input य parameter %d
ह
र (printf
printf("");
ह
value
ह
expression
हआ आ ह. आ printf("Value is %d", 8); यह screen print Value is 8 1st parameter
ह
हऔ
य . यह
य
()
topic
ह
(division).
य (interest) value आ ? 1price*rate*time/100; expression ह. ह
Variable
य ह. *
variable interest define
य
य line
य
य.
ह 1st parameter ह औ screen %d ह ,
ह. %d
ह parameter
ह ह
औ value print ह. ह औ य ह य . ? 1 2 #include 3 int main() { 4 int price; 5 int rate ; int time; 6 7 price = 1000; 8 rate = 5; 9 time = 3; 10 11 int interest; 12 interest = price*rate*time/100; 13 14 printf("Price is %d, Rate is %d, time is %d, calculated interest is %d", 15price, rate, time, interest); 16 scanf("%s"); 17 return 1; 18} 19
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
ऊ य य program यह print Price is 1000, Rate is 5, time is 3, calculated interest is 150 य ह 1st parameter %d ह , ह paremeter ह integer (
य type
)
य operators
आ
Hindi
ह . यय
variable
औ +, - *
.
आ
C/C++ programming language tutorial औ
expressions
ह ह variables औ
. ह
C/C++ hindi tutorial
ह
ह आ
ह! 1. Compiler -
C/C++
program
ह Linux
compile
binary
(replace)
! Windows
ह
gcc filename.c terminal ह.
a.out
ह.
language
यह
a.out ह य ह
ह ह
build
य
run
background
ह! 2. main() function -
ह
C
(execute) ह
program
ह terminal
expression define
variable
3
ह
int x;
define ह
य ह
variable
value ह
declare
ह.
ह, ह
ह, य
execute ह
ह
ह
ह
ह
य
ह
ह
function य program
य
ह memory
य ह ह
compiler x
य य
value
10 ह.
declare ह. य
ह
memory
ह value
.
ह
value ह
ह
printf
यह integer.
datatype,
यह
x
ह variable ह
यय
(value),
(allocate) य(desirable) ह ह.
ह. main
(example int x =10) -
x
ह
ह. printf() function
print
ह आ
expressions 3. Variable declare
ह
ह, ह variables ह.
ह.
memory
ह
= variable
ह.
ह
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
य य
computer address
ह. ह
address
ह. 1 byte
ह. 1 bit
0ह
byte
ह य
8 bits ह
ह.
ह. ह bits
value
ह
memory
store
1.
ह
C/C++ computer programming language
ह.
हआ
1 ..
हय
0 store
ह
sequential bytes
datatypes ह
य य
य
आ ह, 1. int (range)
ह
(real number)
3. char -
(character ह store
number store
हय
य
5. short int - य int
variant ह
6. long int - य
ह
ह.
यह
int
ह
32,767 ) ह,
ह.. 32 bit architecture machine
4 byte
ह.
64
int ह
(
ह.
ह
ह.
positive
variant ह (range)
unsigned short int
0
य
negative value ह
ह.
+4,294,967,295 ह
ह 4
ह.
ह unsigned
ह.
topic(C/C++ hindi tutorial) य (price)
character
+9,223,372,036,854,775,807 ) य
7. unsigned int - य int long int
( −32,768
8 bytes
−9,223,372,036,854,775,808
bytes
Computer 97
ह
variant ह.
bit architecture machine long double
ह,
ह.
memory int
ह
य
variant ह,
यह int
ह ह
ह. (variant)
memory
ह. Computer ह
store
आ यह
ह
4. double - य float
2,147,483,647
1.2, .002 etc.
ह a store
number store
datatypes
float
a,b ...)
ह.
. ASCII table
Computer
(time)
ह −2,147,483,648
ह.
value store
2. float -
ह
ह.
(integer)
(interest)
य
program ह.
ह
य
(rate), code
,
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
य
य ह?
ह
replace
.
int
ह. य
int ह!
ह
ह ह
ह
ह?य
य
code
code
#include int main() { float price; float rate ; float time; price = 1000.0 ; rate = 5.3; time = 3.5; float interest; interest = price*rate*time/100.0; printf("Price is %f, Rate is %f, time is %f, calculated interest is %f", price, rate, time, interest); scanf("%s"); return 1; }
ह
य
य
य
print Note: Fault error य
आ
य
आ
यह printf ह
ह %f
%d
%f float value
आ ऊ
C/C++ program
,
ignore
ह scanf
Hindi
< और > :
Linux
यह Segmentation
Run औ ह
आ
ह comparison operator ह,
output false ह
य ह, %d int
य
.
ह ह. operator Boolean output
य
.
C/C++ programming language tutorial .
ह
ह य यह
3>1 3
आ
ह( ह
output ह true
3 ह ह. 3 < 3
ह ह if-else statement
+, - ...). य
य
ह comparison operator
य statement true ह य false 3 < 1 ka output ह false. output
false ह.
ह3>3
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
<= और >= : य ऊ य
ह
हह ह ह =<
<=
3 >= 3 औ 3 <= 3
य
ह
output true ह ह>य <
.=
य . ह आ
ह .
== : यह
ह
ह. य
ह
यह =
variable
औ
compare
ह.
ह
ह
if statement
हय
value
compare
ह. = assignment operator ह ह,
value
य
ह . यह int, char, आ औ
==
यऔ variable य value
ह.
if else
ह.
format
if(boolean expression1) { statement1; } else if(boolean expression2) { statement2; } ..... .... .... else { statementN; } boolean expression ह ह
value true ह य false.
statement1 execute ह expression2
.
यह true ह
ह boolean expression औ ह
ह.
statement2 execute ह
हआ
ह boolean य .
else
total marks औ obtained marks grade print
.
#include int main() { int total_marks = 500; int obtained_marks = 272; int percent = obtained_marks*100/total_marks;
ह
statement execute ह statement ह
ह.
example आ
.
ह
true
ह
false ह
boolean expression1
boolean expression true ह ह
.
औ percent
.
true ह
boolean expression1
ह percent
,
execute
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in if(percent >= 60) { printf("Congrats!! You passed in 1st division.\n"); printf("Your percentage is %d.\n",percent); } else if(percent >= 45) { printf("You passed in 2nd division.\n"); printf("Your percentage is %d.\n",percent); } else if(percent >= 33) { printf("You just passed in 3rd division.\n"); printf("Your percentage is %d.\n",percent); } else { printf("Sorry! you failed.\n"); printf("Your percentage is %d.\n",percent); } scanf("%s"); return 1; }
ऊ
values value 54.4 ह आ
percent ह
ह
value 54 आ
percent य
ह
condition (percent >= 60)
य
.(यह
program
int
result false आ true ह
condition (percent >= 45) check
यह ह
य ह. )
percent 60
आ
ह
print ह
You passed in 2nd division. Your percentage is 54
condition true ह C/C++ program औ य
\n
print ह
य ह
आ
Hindi
example
line
example
औ output
run
. यह
यह print ह हआ, य
print ह ह
statement ह execute ह
print ह
य . यह आ \n
basic example. #include
ह
printf
ह
value
run
\n
औ output
.
C/C++ program
.
C/C++ programming language tutorial ह.
ह
यह
ह new line character
\n
obtained_marks
य
य
ह.
आ
ह ह if else
औ
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
int main() { int percent = 45; if(percent >= 33) { printf("Congrats!! You passed.\n"); } else { printf("Sorry.! you failed\n"); } scanf("%s"); return 1; }
ऊ
example
percent
ह यह check ह
33)]
value change
percent
screen
program य
value 33
य
run
.
ह [if(percent >=
print ह
Congrats!! You passed.
य
print ह
(else)
Sorry.! you failed
यह
ह
example
ह
य
ह {} speed ह
ह औ
यह 60
,ह
ह. य
ह
.
#include int main() { int speed = 65; if(speed > 60) { printf("Warning: Speed is in danger zone.\n"); } else { }
warning print
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
scanf("%s"); return 1; }
speed 60 य
value
औ
program run
ह
print ह ह
.
य print ह
ह.
speed
ह
program
ह.
#include int main() { int speed = 65; if(speed > 60) { printf("Warning: Speed is in danger zone.\n"); } scanf("%s"); return 1; }
ह
else य
program आ
Hindi
statement
ह
integer
ह ह
else
आ
C/C++ programming language tutorial य ह
.
ह. ह
ह variable
य decide
#include int main() { float v1 = 23; float v2 = 9; float result; char c = 's'; switch(c) { case 'a': result = v1 + v2; printf("Result of addition is %f \n", result);
ह. ह
ह.
example value
ह ह switch case
ह
if else statement if else
ह.
ऊ
य ह.
switch case statement ह आ
ह ह
य example हय
ह...
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in break; case 's': result = v1 - v2; printf("Result of subtraction is %f \n", result); break; case 'm': result = v1 * v2; printf("Result of multiplication is %f \n", result); break; default: printf("No operation selected.\n"); } scanf("%s"); return 1; }
ह. ह
variable c define )
ह
variable c
ह
य
आ
ह ह
आ
यह
औ
आ
Hindi
य
य य
ह
ह
ह ह
c
s
match
औ screen
यह switch() { } block
match ह य
आ
ह case
ह.
ह. ऊ
case
program
c
. float
print
C/C++ programming language tutorial
. for loop
य
case match ह
statement execute ह औ output
case 's':
difference
variable
default
example
statements execute c
यह
switch()
program run
printf आ
औ operator
%f use
य ह.
ह ह for loop ह.
य
%:
ह.
case
v1 औ v2
break ह
execute
औ
य
Result of substraction is 14. break statement run ह
य .
match
aह
. switch
य . switch(c)
result variable
print ह
य
compare य
हआ
type char ह औ value s ह. (char
code
case
s ह. ह case ह ह .
य ह
ह
ह.
example
ह ह.
int a = 15 % 2;यह a
1ह
य
य
15
2
1
ह
.
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
int b = 254 % 2;यह b
0ह
य
य
254
int c = 37 % 10;यह c
7ह
य
य
37
ह for loop
ह.
example
2
0
ह
.
10
7
ह
.
ह 1
example
य
10
square print . ? 1 2 #include 3 4 int main() { int i; 5 int sq; 6 for(i=1; i<=10; i = i+1) { sq = i*i; 7 printf("square of %d is %d.\n", i, sq); 8 } 9 10 scanf("%s"); 11 return 1; 12} 13 ह 2 variable i, sq declare ह
ह
य
य ह.
ह. for()
ह
ह
य
initialization statement आ ह. ह i boolean statement ह
execute ह
यह
check ह
statement य
1 ह,
i execute ह
ह ह
check
example
i
ह.. यह 2ह
य
{}
print ह
screen
{} 1
square of 1 is 1. ह
ह true ह run
{}
ह
i <= 10 true ह
ह. ह
ह.
ह true ह ह
example
sq
check हऔ
;
ह.
ह for
example
statement execute ह
हऔ
statement execute
यह true ह
ह, औ
{}
statement ह
output true य false ह
ह.
execute
ह
.
ह ह.
ह
हआ
execute ह
value 1 ह
ह;
2
य
statement
य statement i = 1 ह
य
.
ह. program
3
ह.
ह
य
false ह ह य
औ
{}
. sq
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
4ह
य
य
i
statement execute ह औ for loop ऊ
program
ह
हi
i
11 ह
ह य
औ {}
i <= 10 false आ
य
य .
run
output
औ program
.
ह .
2 ह.
य
.
ह ह.
value change 1
ह
10
औ output
run
य
ह
print
हय . ? 1 2 #include 3 4 int main() { int i; 5 int sq; 6 for(i=1; i<=10; i = i+1) { 7 switch(i%2) { 8 case 0: printf("%d is even.\n", i); break; 9 case 1: printf("%d is odd.\n", i); 10 break; 11 } 12 } 13 14 scanf("%s"); 15 return 1; 16} 17 ऊ
program
ह
for
switch case statement आय
case print ह
ह
हआ ह
1 is odd.
ह
य
औ i
. ह 1आ
i%2 for
case 0
य
statement execute ह . यह ह
{} block 1ह
i
0आ
ह
for loop
switch case
match ह
print ह
आय
1 {}
for
case 1
match ह
i
2ह
2 is even.
10
switch
i%2
हआ
य . आ
Hindi
runtime
C/C++ programming language tutorial य
य program run ह ह ह
input
आ
ह य ह.
ह example
ह
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
ह.
ह user
example य
हय
य input
औ
यह print
ह
.
? 1 2 #include 3 int main() { 4 printf("Please enter a number: "); 5 int i = 0; 6 scanf("%d", &i); 7 8 printf("You entered %d \n", i); if(i%2 == 0) { 9 printf("Number is even\n"); 10 } else { 11 printf("Number is odd\n"); 12 } 13 14 scanf("%d", &i); 15} 16 program
. यह screen
run
य type
enter
यह
(even) ह य ह ह
program ह
यह screen
ह
ह.
variable आ
ह ह input
store ह
य . ह. Number is even
हर program window
ह
ह
ह.
window
output scanf
printf
ह आ
य
ह
25 enter
ह i
आ आ आ
य
enter
य ह
र : ह
ह-
. यह यह य
यह
यह print
scanf ऱ
ह
ह
आ screen
य 2 य
ह
ह
ह &
.)
ह
य ह
argument &i यह
.
. (यह variable
य ह
print
आ ह scanf("%d", &i);
program य
ह
य
int
औ
ह.
argument "%d"
pointer
screen य ह
य type
variable i define य
line
ह यह
25 ह ह
.
,
input
ह
य .
ह यह
(odd).
.
हह
scanf printf
आ
printf("Please enter a number: ");
य print
ह input ह
यह print
.
यह
Please enter a number: औ
print
0आ
ह
ह% ह
print
Number is odd. आ windows ह program
window
हह
program run
ह ह
ह य
ह यह ह
input
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
ह.
wait ह
य ह output ह
program ब
ह Array
ह
य
.
ह य यह
Array
ह
window
बर .
ह variable define
run ह
program
ह
ह variable ह
ह
ह.
type ह.
value store
value store
variable
integer, character etc.
आ 100 int store
हय
example
ह
value store
ह
ह
array
variable Array
ह.
store
example ह
program
0
य
9
run
square array
औ
store
ह print
.
.
? 1 2 #include 3 4 int main() { 5 int i = 0; 6 int arr[10]; 7 8 for(i = 0; i < 10; i++) { 9 arr[i] = i*i; } 10 11 12 for(i = 0; i < 10; i++) { printf("square of %d is %d\n", i, arr[i]); 13 } 14 15 scanf("%d", &i); 16} 17 ह. int arr[10]; arr variable define यह
ह. य
int store start ह
numbering 0 ... ऊ
ह
arr
program आय
i
int
ह ह
आ
ह 0ह
Array arr
यह 10 int(arr[0] ह. for loop
arr[0] (arr array
ह. य
10 int store
store ह ह. य
number
10 int
size 10
ह ह
ह
ह
ह
int arr[0]
ह
arr[9]) ह store
(
10 int)
0आ
ह
run ह य
,
arr[1] ह.
)
ह हआ
ह
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
ह
आय
for loop ह
ह arr
for loop ह
य
array arr
य .
ह ह.
print
य
array
81 आ
int(arr[9]) ऊ
access
for loop
ह.
आ
Hindi
C/C++ programming language tutorial
य
.
statement run ह
ह ह while loop
ह.
value true आ
ह ह.
य
while loop
य
boolean statement
loop
आ
1
ह.
example य
10
ह
square print
#include int main() { int i=1; int sq; while(i<=10) { sq = i*i; printf("square of %d is %d.\n", i, sq); i = i+1; } scanf("%d", &i); return 1; }
ऊ
program
i<=10
true ह य
य . य य
य
value 1 ह.
i
value 1 ह,
i
ह loop i
i
value 2 ह
boolean statement false ह . यह 1
हआ
औ ह while loop
C language tutorial in hindi औ char type variable What is String ह char variable
square print आ
ह ?
य
boolean statement true ह ह .
i
ह आ
य .
value 11 ह
य
program
.
ह आ आ
ह ह ह
ह ह.
value 1
boolean statement ह statement execute ह
loop
य ह.
य
10
while loop
ह string
ह Array
.
ह.
यह variable
(letter)
word(
य
ह char
array
ह य ,
array
ह.
store ह
)
store ह
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
य
ह
variable store
examples
ह word "hindi"
help
हऔ य
ह word य sentence store
help
औ
store
print
ह.
3
ह important ह.
#include int main() { char w[6]; w[0] = 'h'; w[1] = 'i'; w[2] = 'n'; w[3] = 'd'; w[4] = 'i'; w[5] = '\0'; printf("Word we stored is %s \n", w); printf("1st letter of array is %c \n", w[0]); scanf("%s", w); return 0; }
ऊ program run Word we stored is hindi 1st letter of array is h ह यह ह ह
i ह,
output
ह. ह
ह array
यह
ह यह
ह
use
char
ह य
6 char
string char ह. ह
य ह
\0 ह ह
ह \0 array
print printf statement
printf statement
\n line break character ह 5 char ह ह.
hindi use
string w print
य print
ह. w
string ह
य ह
%s
य ह
%c
य ह. program
य
ह
#include int main() { char w[] = {'h', 'i', 'n', 'd', 'i', '\0'}; printf("Word we stored is %s \n", w); printf("1st letter of array is %c \n", w[0]); scanf("%s", w); return 0; }
1 char
letter read य print ह ह
य
char w[0]
h
2 char ह
आ %s
ह.
ह
letter ह. ह
6 char आ
ह w[5]
word
ह
array
ह
values
print ह
w[0], w[1]...
print
ह. य
value
यह
.
ह
ह.
use
.
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
ह
difference ह हह
values value
ह line
ह
variable
ह.
int x = 1;
हहऔ
define
ह line
int
औ
define
य array
array define
य ह
(
array
length ह
element आय )
array
char w[6] = {'h', 'i', 'n', 'd', 'i', '\0'}; ह
char w[] = {'h', 'i', 'n', 'd', 'i', '\0'}; औ program
ह
ह
ह
ह.
#include int main() { char w[] = "hindi"; printf("Word we stored is %s \n", w); printf("1st letter of array is %c \n", w[0]); scanf("%s", w); return 0; }
ऊ
program shortcut
1 line
difference यह ह
य ह. यह shortcut
use
यह char array use ह
char array
ह.
char w[] = "hindi"; यह
य .
char array w
'i' .... ह
य .
element w[5] '\0' ह ह,
string
ह
element w[0] 'h',
syntax(
ह
य
आ
)
\0 ह
ह.
य
element w[1] . य
recall
ह . ह
blog Reply यह
आ
Hindi
औ
.
ह .
ह function
.
आ
ह important ह. आ
C/C++ programming language tutorial
ह ह function
य if else statement
obtained marks students
य .
आ
ह औ
य
array
आ
topic
ह
function
percentage औ division
total marks औ obtained marks
total marks औ
program
percent औ division
print ह
modify
ह 5
.
यह ह औ
ह.
use
ह
program
ह
program compile
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
run
ह time
.
percentage
य .
औ
यह ह
ह
division print
आ
5
copy-paste
ह function
total marks औ obtained marks program ह
ह,
ह program run ह ह
य
.
ह
.
use. ह
ह ह percentage
division print
function
.
percentage print
program
. य ह.
function define
य
run
औ run
function call
ह
program
यह
.
int get_percent(int total marks, int obtained marks) { int percent = obtained_marks*100/total_marks; return percent; }
ह int example यह
य ह
यह ()
function ह, य
input
ह. य
हआ int यह return ह
ह
ह. ह
ह
ह
. यह 2
. यह ह
function value ह
हह
ह run ह ह
return आ ह function
use
हऔ
ह
ह
ह percent return
function
function
()
यह function int type , य
type
input
ह.
return
int type
ह औ function ह value return
value return
ह parameter य
input int ह. ह
percent
ह ह
input ह
. ह,
input variable
. यह
{}
ह return
function
य यह
access
input
.
function
ह ह input variable
argument
ह
function
ह return
function int type
get_percent ह.
यह
ह
.
ह ह.
(return
).
return statement यह य
program
#include int get_percent(int total_marks, int obtained_marks) { int percent = obtained_marks*100/total_marks; return percent; } int main() { int percent; percent = get_percent(500, 360); printf("Percent is %d\n", percent); percent = get_percent(500, 340); printf("Percent is %d\n", percent); scanf("%d", &percent); return 0; }
ह ह
य
ह. run
.
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
ह ह
औ 2 int type ह int type
ह ऊ start ह
.
important ह.
ह
function
function
ह percent print
ह ह.
percent variable
यह
note ह ()
ह ह.
store
ह
ह
main function
ह
ह
औ program
ह
ह.
ह
value
(
ह
call ह
program
.
ह. main
main function
main method not found. print
main()
return 0;
ह.
आ
error
division
call
main function call ह
sequence ह
ह main()
parameter ह ह
program finish ह
basis
ह ह.
ह
ह
य .
store
function ह
function call
values
औ get_percent function
) औ int return
य ,
.
ह percent print
C program run
ह
return
ह
य .
value 360
य ह
ह. यह parameter
function run ह
ह
main ह
ह
ह
get_percent function call
ऊ
call
value return
आय ह. main
2 parameter 500 औ 360
get_percent percent value 80 percent = get_percent(500, 360); यह get_percent return ह
ह
value 500 औ obtained_marks
total_marks
आ
ह
int type
ह.
य ह.
percent variable define य
define
ह get_percent,
parameter
program run ह
main() ऊ
य ह
function define
run
#include void get_percent(int total_marks, int obtained_marks) { int percent = obtained_marks*100/total_marks; if(percent >= 60) { printf("Congrats!! You passed in 1st division.\n"); printf("Your percentage is %d.\n",percent); } else if(percent >= 45) { printf("You passed in 2nd division.\n"); printf("Your percentage is %d.\n",percent); } else if(percent >= 33) { printf("You just passed in 3rd division.\n"); printf("Your percentage is %d.\n",percent); } else { printf("Sorry! you failed.\n"); printf("Your percentage is %d.\n",percent); } } int main() {
.
run
आ
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in get_percent(500, 360); get_percent(500, 340); int abc; scanf("%d", &abc); return 0; }
example
get_percent function division
difference यह ह
यह function ह void
य ह
main
function
call
ह
return
variable
ह य
ह
ह ह
print
ह ह.
ह ह.
print
function
main
print
यह function
य ह,
ह
return ह
example
,
value function
ह .
store
Exercise: 1.
function print_month
ह function ह
print
ह ,
parameter 2. ऊ
program
print_month call आ
Hindi
variable ह
ह
What is scope C variable ह
.
function
main
use
input
औ
input parameter
आ
scope
यह ह ह. ह
ह.
C function औ C variables
ह.
य
ह
function
variable x define
variable
read/write
ह
variable define ह
ह
{...}
ह ह
declare य define
variable
loop
read/write
program
आ
.
scope
ह आ
ह ह function
.
function
variable
औ
.
value
function
read/write
ह .
print
ह scanf
main
ह October print
10
C/C++ programming language tutorial
ह ह
य ह
call
number ह
.
examples
ह
ह
.
return ह
function
ह
int parameter
define ह
register
ह. य
य ह
य ह
loop
ह. य
य variable
ह
ह
example add
. हऔ
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
ह. program
print register
Menu आय
run
ह य register
name add
ह ह.
print
#include char list[10][20]; int length = 0; void add_name() { if(length >= 10) { printf("list is full\n"); return; } printf("Enter the name: "); scanf("%s", list[length]); length = length + 1; printf("name added\n"); } void print_list() { int i = 0; for(i=0; i < length; i++) { int serial_no = i + 1; printf("%d : %s\n", serial_no, list[i]); } } int main() { int input = 0; while(input != 3) { if(input == 0) { printf("0 - Print this menu\n"); printf("1 - add name to list\n"); printf("2 - print list\n"); printf("3 - quit program\n"); } else if(input == 1) { add_name(); } else if(input == 2) { print_list(); } else { printf("Wrong Input, try again\n"); } scanf("%d", &input); } }
ऊ
program य ह
. List
add enter ह
add ह.
. List print यह
menu print ह
run type 2 Enter ह.
1 press enter . ह
यह
enter
.
य
, add
program
य enter
run
ह
1
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
ह य
यह
ह.
variable
loop ह
ह.
access ह
ह
ह.
यह
य
declare य
access
ह. यह ह ह
ह. यह 10 char
ह
list list
ह 10 array आ
औ ह
. ह.
{1,2,3} ,
{4,5,6}
2 array आ
a
{}
यह char list[10][20]; ह
int a[2][3] ह a = {
function य
char list[10]; ह
.
य ह.
ह
variable ह
10 array आ
20 char
array 20 char
य यह ह ,
10 char आ
array ह
ह ह
य
आ ह char list[10][20]; array ह
2 variable list औ length declare
ह
function
read/write ह
ह
};
ह
औ
array a[0]
a[1] .
array
3 3 int आ
ह. char list[10][20]; array
use ह. यह list
store ह. ह
array letter ह .
.ह
store
ह
10 char array आ
20 char आ
ह
ह
ह
variable length य
string ह
ह
ह 10
ह
char
store ह
store
20 य ह,
currently list
0 ह. add_name function ह ह य
list scanf
आ
10 use
argument "%s" ह
list[0]
य ह
use
ह
add ह ह for loop loop
print ह
ह,
ह. य
scanf
ह ह . list[0],
array ह. ह. list[length] ह list
list[length] (length=0)
length = 1 ह
ह
function
argument char array ह
ह length 1 list
. ह ह check
add
read ह
20 char
print_list function define ह
return
string read
add ह य
ह
list variable
list[1], list[2] ... list[19] list
यह list
call
य ,
ह ह.
char array
list[length] (length = 1)
य ह,
length
ह. यह for loop
access ह ह
ह
.
यह
array ह
ह.
list
variable serial_no define
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
main function ह input variable
ह,
according list
add
ह
. while loop
आ
ह, menu print
ह
ह, list print
scanf
use
input variable
य
आ
use
,
use
value
input read ह, list print
add
use
input read
ह.
ह ह
important
आ
C/C++ programming language tutorial
keywords break औ continue
input
ह.
otherwise while loop
list
scanf
use
ह, menu print
run ह
program finish ह
according if-else
हऔ
Hindi
if-else statement
ह input variable
while loop
input value
ह.
य ह,
while loop
input 3 ह
आ
start ह
value
if-else 3 ह ह
ह program run ह
loops (for loop, while loop, switch case)
ह.
use of break in c/c++
c/c++
ह
loop
ह loop
ह
int array use
array
ह
ह
loop
य
number break
ह
use
. for loop ह example
ह
य.
element ह
break
ह ह,
number
array check ह हह
for loop
ह while loop ह.
ह 100
ह
,
ह ह
ह आ 200
ह . यह for
ह आ
loop
. break
ह
use
य search
int main() { int i; for(i=100; i<=200; i++) { if(i%21 == 0) { printf("1st such number is %d\n", i); break; } } scanf("%d", &i); return 0; }
if statement ह. आ
य
% यह
ह
ह
ह. 21
#include
यह for loop
ह. for
ह number ह ह
check
य
use
य
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
य ह ह ह
for loop
यह for loop
ह if 100
ह
statement i
य
100
break run ह
य ( य ह i
for loop break
ह
use
ह value 105(21
औ for loop
105
while loop
ह break
21
for loop
य औ break run ह
i=105 आ
statement
ह
statement run ह ह
if
ह c/c++
200
if
finally for loop य
value 0 ह ह
i%21
i i
statement run ह .) )ह
य
.
ह
ह run ह
value ह
य .
य . ह. switch case
use
ह.
use of continue in c/c++ ह
ह
loop य
loop
ह ह
run ह ह ह
loop continue array
(for loop, while loop)
number
यह
ह ह
हऔ ह
ह ह
य औ loop
ह.
use
run ह
statement
use
ह
loop
iteration start ह ह.
example
ह. ह continue
ह ह. य,
example य ) print
odd numbers (
. #include int main() { int arr[] = {1,4,7,2,0,-5,8,17,5,-10}; int length = 10; int i; for(i=0; i<10; i++) { if(arr[i]%2 == 0) { continue; } printf("Odd number is %d\n", arr[i]); } scanf("%d", &i); return 0; }
ऊ
example
number even ह
for loop
ह continue
use use
array हऔ
skip
ह. ह while loop
continue
use
ह.
number for loop
ह. आ
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
ह
blog Reply यह आ
आ ह function
.
Hindi
datatype
ह
ह
array
,
store
ह
. struct
length औ width store better version struct
int
store
. य ह 2 int
length औ width store
use ह
use
आय
variable ह
program struct
use
use
य
य
.
int main() { int length1 = 12; int width1 = 8; int length2 = 20; int width2 = 11; printf("Rectangle1: %d %d\n", length1, width1); printf("Rectangle2: %d %d\n", length2, width2); scanf("%d", &length1); }
program
ह ह.
ह
variable
#include
ऊ
ह
store
ह
आय
.
int, char, float, double ह
length औ width store
ह. struct
ह
ह. age store
variable
ह ह structure(struct) ह
data store
store
यऔ
आय
आ
datatype
format
आय (rectangle)
variable 2
ह
.
ह char
ह important ह.
C/C++ programming language tutorial
औ etc. य
ह .
ह
struct
ह. #include struct Rectangle { int length; int width; }; int main() { struct Rectangle rect1; struct Rectangle rect2; rect1.length = 12; rect1.width = 8; rect2.length = 20; rect2.width = 11; printf("Rectangle1: %d %d\n", rect1.length, rect1.width);
use
ह ह,
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in printf("Rectangle2: %d %d\n", rect2.length, rect2.width); scanf("%d", &(rect1.length)); }
य
ह.
हऔ
ह ह
variable length औ width ह. यह Rectangle
datatype ह
ह
य store
य
datatype य
ऊ
य. struct
datatype ह
int
ह
variable
य ह
य . यह rect1
ह
ह आ
object
ह
C/C++ programming
ह Ready ह.
program ह
comment
.आ
ह.
य य define
ह.
ह.
store य हऔ
hindi tutorial
ह pointer ह ,
ह ह
device य ह.
Memory
आ
computer य
ह Memory Structure electronic device
0औ 1
calculator, micro processor, mobile phone य
य
.
ह ह.
ह struct
value length औ width store
struct
ह Memory
Pointer
detail
access ह
ह.
C/C++
ह int
Rectangle
ह struct datatype
य ह यह यह datatype
Rectangle datatype
ह.
ह,
length औ width rect1.length, rect1.width
rect1
. ह
variable rect1 औ rect2 define ह
variable length
ह.
use
ह
{}
error आ
compile
ह
value length औ width
variable
ह.
यह Rectangle datatype
ह Rectangle variable define
ह. यह Rectangle type
ह int
Rectangle
य ह.
datatype य
; ह
variable define
यह
datatype
store ह .
Rectangle datatype define ह
य .
length औ width ह.
ह यह Rectangle
औ width store ह .
ह
ह
datatype
Rectangle
datatype
ह ह
int store
य ह
struct define
ह
ह, आ ह
array
ह
ह ह.
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
1101000110... Memory ऊ
य Array
ह य 1. ह
ह
ह
bit
ह ह. 1 bit
magnetic field
direction
position
memory
bit
direction clockwise ह
ह
bit
read य write ह
ह ह.
computer Memory
य
. हह
0 store ह
0 store ह
य 1. Magnetic
represent
य
ह, aniclockwise ह
computer 0 read
य
position
ह.
1. Computer ह.
8 bits
8 bit
1 byte
ह.
11010001 10011101 00101001 11111001 10000011 00100110 . . . Computer ऊ ह ह
य memory(array)
address ,
ह
ह
bit ह
byte आ
address
Hindi
ह
ह
address
byte level addressing ह
यह
1
store ह
binary
य ) store ह
decimal
convert
computer
ह
1 byte ह.
address
byte
bit
bit. directly ह
byte ( ह
byte
8 bits)
ह. ह byte
ह
.
address ह
ह,
. आ
C/C++ programming language tutorial ह
ह
byte,...
direct address ह ह
.
ह
byte
Computer
bit
11010001.
Memory
byte , य
यह ह
address
10011101 etc. Computer
byte(8 bits) ह
ह
ह ह Memory
1 byte(8 bits) read
00000000
औ
ह.
औ ह 1 bit
0य
य (8
11111111
00000000 औ 11111111 आ
ह ह
ह
ह.
00000000 = 0 (in decimal) 11111111 = 28 -1 = 255 (in decimal) 8 bit य 1 byte ह byte
ह औ ह
char: ASCII table variable
य store ह
255
य
00000000 00000000
ह
0
य store
ह
ह 2 byte
11111111 11111111 य ह
datatype य
ह
store
ह
store
य
(character) computer
ह.
0
store य store ह
65535
.2 ह.
ह. Decimal य
य store
ह.
ह char ह.
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in ह 'a' store
ह
य 97(01100001) store ह
store ह
byte memory
य
255
ह ह
char
table store
1
ह. store ह
short int: short int variable 2 byte(16 bits) ह.
य .
ह. 2 byte ह
short int negative value
य store
65535(216-1)
0
यह -32768(-215)
32767(215-1)
ह. unsigned short int: यह
ह
2 byte
ह
negative value ह
0
65535
ह. int: यह 4 byte
ह औ negative value
unsigned int: यह float:
हऔ
औ
ह
byte
variable(
ह
आ
byte
byte
ह
य
int)
ह.
ह
byte
value
ह.
ह. यह 4 byte
ह.
232-1
ह.
address 0,
ह
value memory
ह.
value
value
computer, memory ह
231-1 0
यह
value
datatype ह
ह
-231
positive value
format complex ह य
double: यह 8 byte
ह
ह
4 byte
store ह
ह
य
ह. ह byte
byte read ह .
address 1... byte
य
ह
ह
variable
ह. address य
byte
store हआ ह
104th byte
address
computer
address
continuous store
int(4 bytes) 101st byte
ह ह.
address 101 हआ.
int
What is Pointer in C/C++ programming language ह ह यह ह store ह stored ह. ह
ह
variable Computer ह
address
address
ह pointer
variable
address
ह variable
ह
यह
ह
memory
ह
variable
value memory
use
य .
ह
address
.
variable int x; ह
ह int, char, float etc
int* datatype
variable
य datatype ह int datatype use
ह.
ह. ह ह
address = ह Memory address/location
(variable
ह.
integer store
store ह
ह ह. C/C++ programming language ह यह
value stored ह). C/C++ programming language &
ह
ह
ह use ह
variable x
address &x
ह
store
ह
address store ह.
ह char variable
address
int variable address store
variable आ
ह
address store
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
char* datatype
ह.
use
example यह show
store
ह.
int variable x define
य ह,
variable
address
ह ह
variable
int x = 5; int* p; p = &x
यह
ह
ह.
address store variable
p variable
address
p
x &
य ह
variable declare य ह.(
address
int
ह
ह
ह.)
use
Address→ 0 1 2 3 4 Memory→ 10000111 11100101 00100110 0000101 01100101 . . . ↑ p = &x = 3 int x ह
variable p ह
print
address print ह
x
ह time ह
p 5
य .(ऊ
हऔ
C/C++ program run
Memory
ह(यह p *p यह
int* type
.
memory
ह xहऔ ह.
address 3 ह
x आ
address
example
औ experiement
address stored ह - means p
यह
हआ
address address ह
memory
x
)य
य stored ह
memory य
x
example
ह यह
*p
use
5 stored ह change
.
#include int main() { int x = 5; int* p = &x; printf("x = %d\n",x); printf("address of x = %d\n", p); printf("value at location p = %d\n", *p); scanf("%d", &x); return 0; }
आ
Hindi
औ
.
आ
C/C++ programming language tutorial ह
C/C++ programming language tutorial
pointer example
datatype ह.
struct hindi #include struct rectangle { int width;
ह
ह. struct
आ
struct
यह click
.
use
ह ह pointer
int pointer pointer ह
ह आ
example ह. ह struct pointer
ह
. C/C++
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in int length; }; int main() { struct rectangle r1; r1.width = 10; r1.length = 15; struct rectangle* r2; r2 = &r1; printf("Original width=%d, length=%d\n", (*r2).width, (*r2).length); r1.width = 20; r1.length = 25; printf("r1 changed, width=%d, length=%d\n", (*r2).width, (*r2).length); (*r2).width = 5; (*r2).length = 10; printf("*r2 changed, width=%d, length=%d\n", r1.width, r1.length); return 0; }
ऊ
C/C++ program
struct rectangle type rectangle
ह.
address store
read
changed value
changed value
r1
address ह
r1
ह. main
य ह औ pointer r2 declare
variable r1 define
औ r2 pointer ह
output यह
.
ह r2
value change
ह
ह
value change
r1
ह struct
r1
variable ह r2
value
read
.
ऊ
program
य
य. r2 address(pointer) ह r1
rectangle
(pointer
address
value *
ह (*r2).width औ r1.width ह
य ह
य ह.
address ह r1
.
य
ह
आ
ह
ह ह
*r2 ह struct
,
*r2 औ r1
ह ह.
change
change
ह.)
Important Note about pointer 1. (*r2).width
shortcut r2->width
औ (*r2).length
ह r2->length
ह
ह. program
ह r2->width
(*r2).width
ह. आ ऊ
program
यह
. 2.
ह
variable declare ह
value
ह(
value ह int x=1;)
आ
( pointer
int x;) औ define declare
य
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
हऔ
address ह
variable
*r2) program crash ह आ
Hindi
औ
.
य
value read
औ segmentation fault
यऔ
आ
output
यह
य
use
. आ
C/C++ programming language tutorial example
(*
ह ह pointer
यह य print
,आ
actual
.
#include void add1(int i) { i = i + 1; } int main() { int x = 5; printf("before adding x = %d \n", x); add1(x); printf("after adding x = %d \n", x); scanf("%d", &x); return 1; }
output यह आ
run
.
before adding x = 5 after adding x = 5
ह
यह output य आ ह ह.
parameter(argument) pass ह
य
ह
ह यह ह
add1 function
x
value 5 ह
य ह
x
x = 5 ह print ह ह ह.
add1 function call हआ copy
ह x
pass
value 5 ह ह औ
य , add1 function
copy
ह ह. main
value 1
x = 5 print हआ ह.
value 1
आ add1 function
pass
value change
य
ह,
variable x original x
value
change ह ह . function call ह य
function ह
original variable
ह
pass
ह.
call
य य
value change ह ह
variable य function , copy
copy
हऔ arguments
value change ह
ह copy call value change
ह.
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
य
C++ program
pointer
य हऔ
use
य
output य ह #include void add1(int* i) { *i = *i + 1; } int main() { int x = 5; printf("before adding x = %d \n", x); add1(&x); printf("after adding x = %d \n", x); scanf("%d", &x); return 1; }
output यह आ
run
.
before adding x = 5 after adding x = 6
ह ह
यह function call
int variable
x ह, औ
address
य
value
य . यह add1 function int value ह
address
ह
1
ह. main
add1 function x
address
address
य ह
copy
change
variable
call
x
value change ह ह
ह ह ,
variable original variable
य . add1 function
address
य
add1 function
ह ह original address ह य address ह
change ह
य ह. ऊ
address pass
add1 function
ह ह.
value change
x
store variable
address
store
copy, address change
ह
य .
Array and pointer आ
Hindi
C/C++ programming language tutorial
आ
ह ह array
pointer
address store ह
ह. A
address ह
य ,
. ह array define int A[10]; A[0] = 0; A[1] = 10; A[2] = 20; ... A pointer ह ह ह. A array ह
position
int
address ह,
ह. ह A+1
position
int
position
int
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
A+2
position
int
A address ह ह
address ह
address ह
0आ
*A
20 आ
*(A+2)
...
. य
*(A)+1 औ *(A+1)
position
stored value आ
position
position(index)
A[0] = 0 ह), *(A+1)
(ऊ 1
position
value
ह
,
10 आ
ह ह. *(A)+1
हA हA
*(A+1)
stored value.
,
हह
ह array
ह. A[n] औ *(A+n)
access
ह.
example
? 1 2 #include 3 4 int main() { int A[] = {1,2,3,4}; 5 printf("[%d, %d, %d, %d]\n",A[0], A[1], A[2], A[3]); 6 7 *A = 10; 8 *(A+1) = 20; 9 *(A+2) = 30; 10 *(A+3) = 40; 11 printf("[%d, %d, %d, %d]\n",A[0], A[1], A[2], A[3]); 12 A[0] = 0; A[1] = 2; A[2] = 4; A[3] = 6; 13 printf("[%d, %d, %d, %d]\n", *A, *(A+1), *(A+2), *(A+3)); 14 15 scanf("%d", A); 16 return 0; 17} 18 run output यय .
void pointer ह variable
pointer address store ह
ह
variable
य यह ह
example
. int* p
? 1 #include 2 int main() { 3 void* p; 4 int i = 65;
p int
address store
address store ह
help
य यह
define
ह value ह int ह.
ह.
ह
. void pointer ह ह void pointer
ह
ह value
ह ह य char य float...
ह ह
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in p = &i; printf("int value = %d\n", (int) *p); char c = 'h'; p = &c; printf("char value = %c\n", (char) *p);
5 6 7 8 9 10 11 12} 13 14 ऊ
scanf("%d", &i); return 0;
example
ह.
pointer define
य
datatype
variable
यह pointer ह ह
program ह
int ह
ऊ
.
य ह
value
malloc and free
ह
pointer
ह(
आ
य
ह
struct
struct ह.
ह memory use
memory
ह malloc.
ह
int 4 byte
यह *p
typecast
ह
ह) औ pointer
4 byte memory allocate ह
malloc(4) call
य ह
ह (int)
य ह. void pointer
variable define
ह. memory allocate
address
typecast
य (typecast) ह. य
य
memory allocate ह
variable
ह
address store
औ
value
ह
datatype
int
ह
value
ह यह
य value
य
value read
void pointer
int
ह char
ह, औ
store
,
pointer
य.
ह int pointer
void pointer
य
ह. ऊ
value ह
stored value
ह
य value int
आ
ह
य
void* p
.
ह
example
य (int) *p
print
int ह
datatype value stored ह
datatype
char
value
ह ह
program
address
ह
int* p
address store
य ह
address store
program
य ह
ह,
औ
address return ह
malloc(4) call
int
य . memory
. malloc
memory
string double char array store ?
ह
address , ह
type
malloc void pointer (void*) return
ह int ह य float ह.
use int
.
1int* i = (int*) malloc(4); //malloc void* 2pointer(int*) typecast य य 3*i = 1; printf("%d",*i);
ह
data
ह.
int
int
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
system function ह
int
ह sizeof
sizeof(int) 4
ह,
memory यह
ह
आ
(
ह ह).
int 4 byte
ह.
4 byte ह
ह
datatype
system
malloc(sizeof(int )) use
ह
.C
. ह int ह
10 int store
memory ह
ह
ह. ? 1int* a = (int*) malloc(10*sizeof(int)); 2int i; 3for(i=0;i<10;i++) *(a+i) = 12;// *(a+0), *(a+1), *(a+2), *(a+3) ... etc यह malloc(10*sizeof(int)) 10 int memory औ memory ह byte address
ह
. store ह
(a+1)
use ह
use
ह)
य
user
य
(आ
ह
input
ह
byte(a)
. (a+1)
*(a+1) *p
ह
int store
.
byte
address ह
ह
address(pointer) p
.
byte य
int
address
value store/read
value store/read
ह
? 1int* a = (int*) malloc(10*sizeof(int)); int i; 2for(i=0;i<10;i++) scanf("Please enter number: %d", a+i);// *(a+0), *(a+1), 3*(a+2), *(a+3) ... etc आ variable use
variable define ह
use ह
memory
ह
ह
आ memory
ह memory
आ free ह
आ free ह ह
.
ह.
ह.
आ आ
malloc
आ free call
free
. for example ? 1int* a = (int*) malloc(10*sizeof(int)); 2//use memory 3free(a); memory free ह आ program memory(RAM) आ
memory य ह औ
C
system slow य hang आ free ह
memory
basic
य ह,
related
.
ह
ह.
ह
य .
ह program
ह ह
ह.
#include य
हय ह
.आ
यह
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
ह
ह program
ह.
य (process) ह
(steps)
computer
ह ह program
ह. आ
ह
ह
ह
ह step
program
ह
compile
stdio.h file
ह.
यह
ह य
error आ
य
ह
ह
आ
program ह
run
function defined ह आ
print
ह function stdio.h file
ह
ह. file(stdio.h)
आ ह. printf output ह.
ह
defined ह औ
printf function ह
input/output
defined (declared) ह.
ह ह.
pre-processing
ह Standard Input and Output.
stdio
file
compiler #include
process
printf function
ह
ह.
ह step
content
य
ह ह यह
.
function ह. यह function stdio.h
printf
machine
. यह compile
compile
#include य
program
ह.
ह,
ह
scanf input
defined ह.
Pre-processing program ह process
start ह
line # program
ह
#define ABC 1 #define constant ह
ह program
macro
ह
ऊ
file
content
ह
य य
define ह
ABC
ह ह. Compiler ह step य
य ह. #include ह
ह.
preऔ
य ह. य
ह. #define ABC 1
ह 1 compiler ह step
1
. #define
ह ह.
#define ADD4(a) (a+4) यह macro ह parameter step
ह.
modify
processing directive ह pre-processing directive ह
ह pre-processor
ADD4(x)
औ . #ifdef xyz ... #endif ह #define
ह
ADD4(5)
use
xyz
ह. ह (x+4) ह
ह define
use य
program compile ह x
ह (5+4) ह
य ह
ह
1st ह, variable य
य .
#ifdef औ #endif
हआ
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
program compile ह Note:
य
हआ program ह
pre-processor
line
य
pre-processor
line
ह
ह.
ह
,
example ह
#include
य . य
line य
आय ह.
य
program ह
pre-processor य .
य pre-processor commands
example
ह. ? 1 2 #include #define AREA(r) (PI*r*r) 3 #define PI 3.14159 4 5 int main() { 6 int rad = 10; float area = AREA(rad); 7 printf("Area of circle is %f\n", area); 8 9 scanf("%d", &r); 10 return 0; 11} 12 ऊ
program
(3.14159*rad*rad) ह function
य . य
ह
ह
यह function call
ह ह. function call
ह value area
return य
(3.14159*rad*rad) ह
ह (PI*rad*rad) औ
AREA(rad)
यह
हऔ
य यह
function call
ह
AREA(rad)
value calculate
ह.
area
Arithmetic Operators आ
Hindi
C/C++ programming language tutorial
operators
औ
operator य
य . operator
य
आ
ह ह arithmetic
. हह ह
function ह औ output
ह(
ह return
ह)
य ह. 1. +: यह
य
a = 5+3 2. -:यह
हऔ a
य
value 8 ह हऔ
sum return
ह.
5+3 8 return
ह. difference return
ह.
,
ह,
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
3. *:यह
य
हऔ
4. /:यह
य
हऔ
य
5. %:यह
य .
operator ह
variable
return value
right side ह.
ह य . ? 1int a = 5; 2int b = 3; 3a = b; य ऊ
ऊ
example
य
=
. यह
य
left side
a+b
value ह आ
c
variable ह ह
c
.aऔ b
8 return save ह
य
यह
य ह.
save
expression
c = a+b
left side
operators
a
variable
right side
c
value) आ ह , , य
यह
right side
value 8
य ,b
5 ह
ह,
value
program error औ ह
left side
a+b 8
3(b
variable ह ह
a+b ह. =
d = (c=a%b)
value
right side
a=b
return ह. ? 1int a = 5; 2int b = 3; 3int c,d; 4d = (c = a % b);//% ऊ example c = a%b ऊ
य ह
= 5; = 3; = a + b;
variable
आ
ह
य
add
ह
. return value 8
example
ह.
(remainder) return
ऊ operator arithmetic operator ह. ? 1int a = 5; 2int b = 3; 3a + b; ऊ program line a औ b lost ह ? 1int a 2int b 3int c =
ह.
(divisor) return
हऔ
value change ह ह
ह.
product return
औ
ह ह.य
a+b = c
left side expression
value
ह.
c
value 2 ह
return value ह
d
य आ
input(int,float etc.)
औ यह(c=a%b) 2 return य . ह
ह
output
ह.
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
3आ
30/8 ह आ
. 30 औ 8
int ह
ह
,
ऊ
य . agar 30.0/8.0
operator, binary operator ह. ह
औ ++x x य
ह variable x
य value return use
य
ह
expression
य
ह.
ह
ह. value return
x++ य ++x
.
.
2
ह. x++ x
value 1
,
3.75 आ
यह हआ
unary operators 1. x++ औ ++x : य
int आ
result
ह
य
ह .
हह औ
example
ह
य . ? 1int a 2int b 3int c 4int d ऊ
= = = =
5; a++; ++a; (b++) + (++c);
line run ह
program ह
value return 7ह b
य
औ c
य
7
value 5
b य
6, c
a य .
5
6ह
value 1 line run ह
a
य value return
++a a
8ह
value 7
य
य ,d
a++ value 6
ह.
line run ह
य (d = b
13
value +
ह value = 5+8)
c
x-- औ --x औ --)
ह int(
ह
यह x
ह. float औ double datatype
)
ह. य
value 1
operator(++
error आ
use
.
Binary Number System आ
c++ programming
य
1. Binary Number System decimal औ decimal
Binary
binary
ह
ह
ह
0
ह
9
logical operator
ह. ह
.
ह.
ह
use ह
ह( य ह
ह
6 ह).
5 1
ह.
.
.
य
य हऔ
ह ह,
convert ह
0
ह logical operators
ह.
.
आ
आ
hindi tutorial
85 ह,
59
60 आ
ह य
9ह
ह. 86
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
ह(
0
आ ह
ऊ
0 य
ह)
9
0ह
7
ह
ह ह.
8
य ह. 7
य औ
10 आ
य.
8
य , य
?
ह
0
ह ह.
7
हह . 0,1,2,3,4,5,6,7, 10,11,12,13,14,15,16,17,20, 21,22 .... 71,72,73,74,75,76,77,100,101,102 ... ह य य ह ऊ य य ह. ह ************ आ य
ऊ
0
ह ह
7
आ
discussion site *ह
आ
आ ह ह. ऊ
10,base 10)
use
ह
य
0
य 14 = 4x80 + 1x81 = 8 + 4 य ह ह
आ
7
8
8,base 8)
ह ह. ह
ह
य 14
.
use
system
Counting system 12
octal system
ह ह
8
ह
. ह. *
system 14
3
ह ह
4
ऊ
*
ह ह,
decimal
. ह
0,1,2,3,10,11,12,13,20,21,22,23,30,31,32,33,100,101,102 ... 4) ह ह.
ह, decimal
.
ह
0
ह
10
.
12 औ octal system ह
9
ह
य ह 0 1 12 = 2x10 + 1x10 = 10 + 2 Octal system(आ 8,base 8)
system
).
0
octal system(आ य
आ
12.
14(ऊ
system(Counting system) system(आ
ह.
discuss
य
.
Quaternary system(आ
30
4,base
.
ꜜ**** * * * * * * * * decimal(0-9
) 1 2 3 4 5 6 7 8 9 10 11 12
0-7
1 2 3 4 5 6 7 10 11 12 13 14
0-3
1 2 3 10 11 12 13 20 21 22 23 30 -
8
13, base 4 य
use
यह
base 23
य .आ
ह ह
ह.
य base
य
11(base 10)
य य
base
ह base 10 base
ह.
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
base 8
75 = (75)8, base 4 य
base
123 = (123)4 य
base 10
य
convert
य
.
ह ह.
example
(75)8 = 5x80 + 7x81 = 5x1 + 7x8 = 61 (base 10 ) (123)4 = 3x40 + 2x41 + 1x42 = 3x1+ 2x4 + 1x16 = 27 (base 10 ) य
base 10 base
य base ह
convert
य
convert ह
.
. य
base
ह ह
. यह process
base
य
ह
ह ह
0
आ
य .
य . य.
example
ह ह. 98
base 8
98/8 = 12( 12/8 = 1( 1/8 = 0(
example: ),2(
) ---> 2( ) ---> 4( ह )
), 4( ), 1(
)
) --> 1 (
)
98 = (142)8 98
base 4
98/4 = 24( 24/4 = 6(
example: ),2(
) ---> 2(
)
) ---> 0( ह )
), 0(
6/4 = 1(
), 2(
) --> 2 (
1/4 = 0(
), 1(
) --> 1(ह
) )
98 = (1202)4 ह
Binary Number System:
2
ह ह
- 0 औ 1,
ह
ह
: 0,1,10,11,100,101,110,111,1000,1001,1010,1011,1100 ... ह 98
ह, Binary system( base 2
आ
)
ह ह.
example:
98/2 = 49(
),0(
) ---> 0(
)
49/2 = 24(
), 1(
) ---> 1( ह )
system
2
ह
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
24/2 = 12(
), 0(
12/2 = 6(
) --> 0(
), 0(
)
) --> 0(ह
)
6/2 = 3(
), 0(
) --> 0(
ह
3/2 = 1(
), 1(
) --> 1(
)
1/2 = 0(
), 1(
) --> 1(
)
)
98 = (1100010)2 1100010
base 10
example:
0
1
2
(1100010)2 = 0x2 + 1x2 + 0x2 + 0x23 + 0x24 + 1x25 + 1x26 = 0+2+0+0+0+32+64 = 98 logical operators
.
logical and comparision operator आ
ह C programming ह
ह operators
औ
.
ह ह.
Logical operators
1. ! - यह
आ
hindi tutorial
uniary operator(NOT) ह,
हऔ
bool value
ह,
!true = false, !false = true 2. || - यह ह
binary operator(OR) ह
य
ह.
false
3. && - यह य
ह.
true
ह ह AND य (false) ह
), य
use
1. == - यह bool value true 2. != - यह ह ह
ह
.
result ह (true) ह
.
use ह
ह.
. य
false
ह.
binary operator (not equal) ह
bool value true
(false) ह
result
य .
binary operator(equal) ह ह
ह (true) ह
ह (true) ह
(false) ह
result
false ह
(य ), य
(false) ह
. औ (
ह
bool value
OR य
Comparison Operators example
true
true || false = false, false || false = false
ह
result ह (true) ह
true ह
true || false = true, false || false = false
binary operator(AND) ह
ह
false
ह
bool value
ह
य
false
int य
bool value
ह,
ह
(5 == 5) = true , (1 == 2) == false int य ह.
bool value
ह,
(5 != 5) = false , (1 != 2) == true
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in
3. > - यह
binary operator (greater than) ह
value true
ह
4. < - यह
binary operator (less than) ह
value true
ह
3. >= - यह य true 4. <= - यह ह
य
ह,
int value
ह
ह
य
ह
यह print
28 ह
ह
ह
ह
ह
ह
य
ह
bool
ह,
ह
int
य 29
.(
(5 > 5) = true , (3 > 2) ==
ह.
ह
(i %100 !=0)
य ह
य(1984, 2012) य
4 400
int
(5 < 5) = true , (1 < 2) == true example
य ह
ह,
int value ह.
false ह
int value ह.
false
use 100
य check
bool
int
(
औ
) input य
4 ह ,
400
1900,2100... 28 ह 2000 29 ) ? 1 2#include void main() { 3 int i; 4 printf("Enter the year: "); 5 scanf("%d",&i); 6 if(i%4==0 && i%100!=0) printf("Feb have 29 days"); if(i%400==0) printf("Feb have 29 days"); 7 else else printf("Feb have 28 days"); 8} 9 % यह ह आय . 0 आय example
ह
int
(5 < 5) = false , (1 < 2) == true
binary operator (less than or equal) ह bool value true
ह
(5 > 5) = false , (3 > 2) == true
ह.
false
bool value true
example 29
ह.
false
binary operator (greater than or equal) ह ह
य
य
ह,
int value
य.
य(i%4 ==0 ) औ (&&) 100 य.
ह. ? 1 #include 2void main() { 3 int i; 4 printf("Enter the year: "); 5 scanf("%d",&i); 6 if((i%4==0 && i%100!=0) || i%400==0) printf("Feb have 29 days"); else printf("Feb have 28 days"); 7} 8
C/C++ Programming language tutorial in Hindi: Introduction http://programming-tutorial-hindi.blogspot.in