Its easy to understand C programming for SEE C is a powerful general purpose programming language. It can be used to develop software like operating systems, databases, compilers, and so on. C programming is an excellent language to learn to program for beginners.
Click Here to Learn QBASIC For SEE
Characteristics of C programming for SEE :
–> is a general-purpose, block structured, procedural computer programming language
–> Developed in 1972 A.D. by Dennis Ritchie at the Bell Telephone Laboratories.
–> C language is the mother language of all other programming language
–> All other languages are developed from the base of C language like C++, Java, C# etc
–> UNiX operating system is also developed by using the C language.
–> It is 3rd generation language(3GL)
–> Both High Level and Low Level Language (Mid-Level Language)
–> It uses compiler.
C Programming | QBASIC |
i. Uses Compiler | i. Uses Interpreter |
ii. Mid-level language | ii. High Level Language |
iii. Mother of all languages | iii. Basic Language |
iv. Advanced programs/software’s can be developed | iv. Advanced programs cannot be developed |
a. Character Sets in C language
- C language has 98 character sets.
Characters | Name | Count |
A-Z, a-z | Letters | 52 |
0-9 | Digits | 10 |
, ; : ? ‘ ” ! @ $ # % ~ > < = & _ – + * ) ( ] [ {} / \ | . | Special Characters | 31 |
Blank Space, horizontal tab carriage return, new line, from feed | White spaces | 5 |
Total | 98 |
IT Service in Pokhara Click Me
b. Keywords :
Keywords are the set of words in C language meaning and actions of which remains fixed throughout the language. There are 32 keywords.
auto | break | case | char | const | continue | default | do |
double | else | enum | extern | float | for | goto | if |
int | long | register | return | short | signed | sifzeof | static |
struct | switch | typedef | union | unsigned | void | volatile | while |
c. Data Types
There are 4 basic data types
i. Primary or Fundamental Data types
ii. User Defined Data Type
iii. Derived Data Type
iv. Empty Data Type
i. Primary or Fundamental Data Types
The primary data types are built in and with the help of that data type we can create all other data types. Primary or fundamental data Types are again divided into three types.
Data Type | Memory Occupies (Bytes) | Scan Format | Code/Short form |
integer | 2 | %d | int |
Floating Point | 4 | %f | float |
Double | 8 | %lf | double |
Signed Character | 1 | %c | char |
Operators:
Operators in C is similar as the operators in QBASIC. Operators are the special symbols which perform certain calculation to the operands. For eg; a + b ; here a and b are operands and “+” is the operator.
a. Arithmetic Operator.
Operators | Meaning |
+ | Addition |
– | Subtraction |
* | Multiplication |
/ | Division |
% (same as MOD in QBASIC) | Modulo Division |
( ) | Brackets |
b. Relational/Comparison Operator
Operators | Meaning |
< | Less than |
< = | is less than or equal to |
> | Is greater than |
> = | Is greater than or equal to |
= = | is equal to |
!= (QBASIC < > is not equal to ) | is not equal to |
c. Logical Operator:
QBASIC | C-Operators | C-Meaning |
AND | && (ampersand) | Logical And |
OR | || | Logical Or |
NOT | | | Logical Not |
d. Assignment Operator.
= is the assignment operator.
A= 5; we assign the value 5 to variable A .
Without Short Hand Operators | With Short Hand Operators/ Supported by C |
a = a + 1 | a+=1 |
a = a – 1 | a-=1 |
a = a * (n+1) | a*=n+1 |
a = a / (n+1) | a/=n+1 |
a = a % b | a%=b |
e. Increment & Decrement Operators:
Without Increment Operator | With Increment Operators |
a=a+1 | a++, ++a |
a= a-1 | a–, –a |
f. Ternary Operator or Conditional Operator in C.
We use ? as Ternary Operator.
Syntax:
(Condition) ? for true body: for false body
eg;
a=10, b= 20, c= 30
(a>5) ? b = b +5, c = c-5
After execution;
b= 25
1. display
Syntax :
printf (“Message/scan format”, list of variables);
eg;
void main(){
int a,b,c;
c = a + b;
Printf (“The sum of %d and %d is = %d”,a,b,c);
}
2. To take input from keyboard
Sytax:
scanf (“scan format”,&variable, &variable);
eg;
void main(){
int a,b,c;
printf(“Enter first number”);
scanf (“%d”,&a);
printf(“Enter the second number”);
scanf (“%d”,&b);
c = a + b;
printf(“The sum of %d and %d is = %d”,a,b,c);
}
3. Variable Declaration.
eg;
int a;
float b;
double d, e, f=50.90;
Conditional Statement
QBASIC | C-Programming |
1. If condition then *** body of if *** It is shown if the condition is true End If | 1. If (condition) { *** body of if *** It is shown if the condition is true } |
2. If condition then *** body of if *** It is shown if the condition is true else *** body of else *** It is shown if the condition is false end if | 2. If (condition) { *** body of if *** It is shown if the condition is true } else { *** body of else *** It is shown if the condition is false } |
3. Multiple If/Compound If | 3. Multiple If/Compound If |
If condition then *** body of if *** It is shown if the condition of if is true else if *** body of if *** It is shown if the condition of else if is true else if *** body of if *** It is shown if the condition of else if is true else *** body of else *** It is shown if the condition is false end if | If (condition) { } else if (condition) { } else if (condition) { } else if (condition) { } else { } |
Q1.
1-5= Child
6-12= Baby
13-19= Teenager
20-49= Adult
50-69= Old
70-84=Jestha Nagarik
85 Above= too old
ANs :
void main(){
int a;
printf (“Enter your age”);
scanf (“%d”,&a);
if (a>0 && a<=5 ) {
printf (“YOu are Baby”);
}
else if (a>5 && a<=12)
{
printf (“you are Child”);
}
else if (a>12 && a<=19)
{
printf (“you are Teenager”);
}
else if (a>19 && a<=49)
{
printf (“you are Adult”);
}
else if (a>49 && a<=69)
{
printf (“you old”);
}
else if (a>69 && a<=84)
{
printf (“you are Jestha Nagarik”);
}else if (a>84)
{
printf (“you are Too old”);
}
else
{
printf (“Try Again by Entering the valid age!!!”);
}
}
Q2.
1-3= Pre-Primary level
4-5= Primary level
6-8= L.Secondary
9-10= Secondary level
11-12= H. Secondary Level
13-16= BAchelor level
17-18= Masters Level
19-20= Before pHD level
21-25= phD level
Try Again please input the valid class
Q3. WAP to find If the number is even or odd.
void main(){
int a;
printf (“Enter any number”);
scanf (“%d”,&a);
if (a % 2 ==0)
{
printf (“The number is even”);
}else
{
printf (“The number is odd”);
}
}
Q4. WAP to find if the number is +ve, -ve or zero.
Iterative Statements/Looping Statements.
Iterative statements perform the same set of statements zero or more time depends on the condition are repetition of job. When we want to do the same type of job in a finite or infinite number of times then we take the help of iterative/looping statements.
Iterative/Looping is the statement which executes its body till the condition is true and terminates if the condition is false. There are also three types of iterative/looping statement used in C-programming. They are:
i. for statement | ii. while statement | iii. do-while statement |
syntax: for (initialization;condition,incr/dec) { body of for; } | syntax : initial variable; while (condition) { body of while; counter; } | syntax: do { body of do-while; counter; }while (condtion); |
eg; void main( ){ int a; for (a=1; a<=5; a++) { printf (“%d “, a); } } | eg; void main( ) { int a; a=1; while (a<=5) { printf (“%d”, a); a+=1; } } | eg; void main( ) { int a; a=1; do { printf (“%d”, a); a+=1; }while (a<=5); } |
Questions :
1. WAP to print 1 3 5 7 9 up to 10th term.
2. WAP to print 100 99 98 97 96 95 .. up to 11th term.
3. WAP to print fibonic series 1 1 2 3 5 8 .. up to 12th term
4. WAP to print hailstone series 6 3 10 5 16 .up to 12th term.
5. WAP to find sum of first five natural numbers.
6. WAP to find sum of first 100 natural numbers.
