Вы находитесь на странице: 1из 15

Important Notice

C/C++ computer program run .

online, click

compiler . .

Install

"Run Program Here" . . save

compiler

program (execution)
program
===Windows ===

1 . dev-c++ open 2. Dev-C++ .( 3 . File

. (Start -> All Programs -> Dev-C++) ( "Tip of the Day" tips program . . ) window )

New

Source File .

#include <stdio.h> int main() { printf("Namaskar"); scanf("%s"); return 0; }

4 . menu Execute ->Compile : program Compile Error . .

. spelling program window output .

5 . menu Execute -> Run .


==Ubuntu Linux ==

Namaskar.

1. 2. program

text editor (vim , gedit , emacs ...) namaskar.c program . .c

. C .

. .

#include <stdio.h> int main() { printf("Namaskar"); scanf("%s"); return 0; }

3. terminal . ls : current . . cd .. : current . cd <

cd command .

4 command

>: current full location

. pwd : current 4.

gcc namaskar.c

Enter

compile 5 . Run
./a.out

. .

error

namaskar
==============

. .

Run

program (comment ) ,

Run

. C/C++ program

error :

!!

C/C++ computer program "Run Program here" . click

C/C++ program Run Hindi ?


1 #include <stdio.h> 2int main() { 3 printf("Namaskar"); 4 scanf("%s"); return 0; 5} 6

C/C++ programming language tutorial program . program

C/C++ program . line function . program program program printf


program

screen line

Namaskar

program

printf("Namaskar"); "" . line Namaskar

. C printf screen

output lines 2 line changes


points

. 3 line .

line

1.C (execute ) 2.printf function .

program }

run main() { line (

main() { program function function semicolon (;) . use ), run .

program run

2 line execute method input

function

3. function . semicolon ? compiler command program . .

function

1 #include <stdio.h> 2int main() { 3 printf("Namaskar") 4 scanf("%s"); return 0; 5} 6

program compile In function `int main()': error: expected `;' before "scanf" Execution terminated scanf ; . function . ; .

error

, compile

compile

program printf

program program modify

compile compile .

topic variables . link .

program , interest(

calculation

facebook twitter Google Buzz

Share

Index Next Hindi C/C++ programming language tutorial variables expressions . variables in C/C++ programming language Variable , variable define C/C++ program ?
1 2#include <stdio.h> int main() { 3 int x; 4 x = 1; 5 x = 5; 6 scanf("%s"); 7 return 1; 8} 9

. define .

variable use

. .

program line 3 line add program line

program . x variable 3 line int x;

printf .

1. int

main() {

variable define

int

integer

. integer ( 2. x
= 1;

int temp; ) . define . .

temp

variable define

variable x x 1

C/C++ program

line x

. 5

line .

variable define

Expression in C/C++ programming language Expression example . ?


1 2 #include <stdio.h> 3 4 int main() { 5 int price; 6 int rate ; int time; 7 8 price = 1000; 9 rate = 5; 10 time = 3; 11 int interest; 12 interest = price*rate*time/100; 13 14 scanf("%s"); 15 return 1; } 16 17

program set

3 variable: price, rate, time define . variable interest define interest variable (interest) .* value (division).

value

(multiplication) /

?
1price*rate*time/100;

expression . . expression Variable screen +, -, *, / . value screen

150 ()

interest

value 150

print .

(printf

) .

topic

printf(""); ""

line . printf("Value is %d", 8); screen print Value is 8 printf function 2 input parameter paremeter print ?
1 #include <stdio.h> 2 3 int main() { int price; 4 int rate ; 5 int time; 6 1000; 7 price==5; rate 8 time = 3; 9 10 int interest; 11 interest = price*rate*time/100; 12 printf("Price is %d, Rate is %d, 13price, rate, time, interest); 14 15 scanf("%s");

parameter %d %d ,

. printf %d parameter parameter

1st value .

. 1st parameter screen . .

value print

time is %d, calculated interest is %d",

16 } 17 18 19

return 1;

program print Price is 1000, Rate is 5, time is 3, calculated interest is 150 1st parameter %d , paremeter integer ( . ) !! type link Share variable . .

+, - *

operators

facebook twitter Google Buzz Hindi variables expressions C/C++ hindi tutorial 1. Compiler terminal Windows ! C . main 2. main() function . printf() function terminal print expressions ! C/C++ . compile . a.out

C/C++ programming language tutorial .

program a.out build program

Linux gcc filename.c binary ! background (replace) run (execute)

language

expression printf .

3. Variable declare datatype, . (allocate) variables value value computer . 1 .. bits . bits 0 store . declare . . (value),

define variable integer.

(example int x =10) 3 , x

10 .

int x; define

declare value ,

variable compiler x

value memory function program

memory . = variable memory . memory address value store 1. variable .

(desirable)

execute

address

sequential bytes byte 0 . . 1 bit . 1 byte 8

C/C++ computer programming language , (integer) .

datatypes

1. int -

2,147,483,648 .

2,147,483,647 (range)

value store

2. float etc. 3. char Computer a store

(real number) a,b ...) store character store .

1.2, .002 .

(character number

Computer 97 store number store .

. ASCII table

Computer

datatypes 4. double . 5. short int int 6. long int machine int int 4 byte float

variant float variant , int variant . int

(variant)

memory memory

. ( 32,768 .. 8 bytes . 32,767 ) ,

32 bit architecture (

64 bit architecture machine

9,223,372,036,854,775,808 . 7. unsigned int . +4,294,967,295 unsigned short int . . int .

+9,223,372,036,854,775,807 ) . negative value (range) unsigned long int 0 variant

long double 4 bytes positive

topic(C/C++ hindi tutorial) (rate), (time) code (price) ,

program (interest) int .

! replace

code

int

? code

#include <stdio.h> 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; }

, %d int print

printf %d

%f %f float value

Note:

Segmentation Fault error ,

C/C++ program

Linux Run ignore scanf

. Hindi ( ,

C/C++ programming language tutorial . +, - ...).

if-else statement

comparison operator . operator

comparison operator Boolean output statement true true 3 false

< >: false. output

3>1 3>3 false . . > . <

output

3 < 1 ka output 3 .3<3

output false

<= >= : output true .=

3 >= 3 3 <= 3 <= value = =< . . int, char, . = assignment

== : compare

operator == format

variable value

compare

value .

variable if else .

if statement

if(boolean expression1) { statement1; } else if(boolean expression2) { statement2; } ..... .... .... else { statementN; } boolean expression expression1 expression1 true true false value true false. boolean .

statement1 execute . boolean expression2

. boolean .

statement2 execute ,

boolean expression statement execute else .

true

boolean expression true .

statement

execute

percent

example

percent

total marks obtained marks grade print .

#include <stdio.h> int main() { int total_marks = 500; int obtained_marks = 272; 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); } scanf("%s"); return 1; }

program

values int

.)

percent value 54.4 percent 60 result false

value 54

.(

percent condition (percent >= 60)


You passed in 2nd division. Your percentage is 54

condition (percent >= 45) check

true

print

execute print print output value . . ,

condition true . \n C/C++ program printf

print \n \n

statement . \n run .

line print

example obtained_marks run output comment

new line character

C/C++ program

topic if else

!! link Share

example .

facebook twitter Google Buzz

Hindi if else

C/C++ programming language tutorial example basic example. .

#include <stdio.h> int main() { int percent = 45; if(percent >= 33) { printf("Congrats!! You passed.\n"); } else { printf("Sorry.! you failed\n"); } scanf("%s"); return 1; }

run

example percent .

value change percent

program value 33 print screen

check

[if(percent >= 33)]

Congrats!! You passed.

print

(else)

Sorry.! you failed

example warning print

{}

speed

60

#include <stdio.h> int main() { int speed = 65; if(speed > 60) { printf("Warning: Speed is in danger zone.\n"); } else { } scanf("%s"); return 1; }

speed

value

program run

print

. speed 60 program

print

#include <stdio.h> int main() { int speed = 65; if(speed > 60) { printf("Warning: Speed is in danger zone.\n"); } scanf("%s"); return 1; }

else

program

else . Share . .

topic switch case statement !! link

facebook twitter Google Buzz

Вам также может понравиться