0% found this document useful (0 votes)
4 views

C Programming For Everyone That Nevver Works

lejfljwjflwsejkfljwslvsnlvlnsllkj
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

C Programming For Everyone That Nevver Works

lejfljwjflwsejkfljwslvsnlvlnsllkj
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Importance of c

The increasing robust language which is written are efficient and fast

32 keywords and highly portable language

Structured programming

Procedural programming

Modular structure

Sample program

Print a statement

#include <stdio.h>;

int main () {

printf (“hello world!”);

return 0;

keywords

auto, break, case, char, const, continue, default, do, double, else, Enum, extern, float, for, goto, if, long,
int, register, return, short, signed, sizeof, static, struct,

switch, typedef, union, unsigned, void, volatile, while.

identifiers

identifiers refer to the name of variables, functions, and arrays.

rules for identifiers

first char must be an alphabet (or _)

must consist of only letters, digits, or _.

only first 31 chars are significant

can't use a keyword

must not contain white space

constants

constants in C refers to fixed values that do not change during the execution of a program

integer constant
an integer constant refers to searice of digits which include decimal, octal, hexadecimal integers. and
non digit chars, ‘,’ spaces are not permitted in numbers.

p
Any number that can be represented by ( form or containing fractional parts) are called real numbers
q
We use these numbers as real constant in C.

e.g., 0.0083

single char constant

a single char constant contain a single char enclosed in single quotes.

e.g., ‘a’

string constant

a string constant contain several chars enclosed with a double quote.

e.g., “hello”

variable

a variable is a data name that is used to store a data value.

a variable may take different values at different time in a program execution.

Rules for naming variables

The variable name should be a meaningful one.

Variable must begin with a letter or ‘_’.

31 chars are significant for a variable name.

The variable should not be a keyword.

White spaces are not allowed.

Variable can only include numbers, letters, and underline (_).

e.g., value john, ph_value, ph_no, …

data types

write a see profram to print ‘hello world!’

#include <stdio.h>

int main () {

int var;
printf ("hello world!");

return 0;

Int add(num1, num2)

Result = num1 + num2;

Return result;

//Write a c program to print sum of 2 numbers

#include <stdio.h>

//main function

Main () {

//defining the variables for input and output

Int num1, num2, sum=0;

//getting the values from the user

Printf (“Enter your first number: “);

Scanf(num1);

Printf (“Enter your second number: “);

Scanf(num2);

//adding the 2 variables

Sum=num1+num2;

//printing the output

Printf (sum);

Write a c program to find the area of a sircle(area=\py r^2

#include <stdio.h>

Main () {

Int r, area=0;
Printf (“enter the radius: “);

Scanf (r);

Float pi=3.14;

Area=pi*r*r;

Printf (“the area is %d”, pi;

You might also like