The document discusses various computer programming concepts in C language including data types, operators, control structures, functions, and algorithms. It provides an overview of different types of languages like machine language, assembly language, and high-level languages. It also explains concepts like variables, expressions, I/O functions, data structures and their implementation in C programs through examples. Flowcharts and algorithms for basic mathematical and logical problems are presented. Different loops and decision making statements supported in C like if-else, switch-case, for, while, do-while are described along with their syntax and usage.
#Code2Create series: C++ is a powerful general-purpose programming language. It can be used to develop operating systems, browsers, games, and so on. C++ supports different ways of programming like procedural, object-oriented, functional, and so on.Start your programming journey and join us to learn C++ basics!
by Google Developers Group and Women Tech-markers Kuwait chapter:
Instagram and Twitter: @GDGWTMKUWAIT
C programming_MSBTE_Diploma_Pranoti DokePranoti Doke
"1.1 Structure of ‘C’program, Assembler, Linker, Compiler, Interpreter.
1.2 ‘C’character set-keywords, identifiers, types of constants (Integer, single character, string, and real) variables, scope of variables, concept of ASCII.
1.3 Data types: integer- unsigned, signed, long, float- float, double, character char, string, octal, hexadecimal
1.4 Algorithm and flow chart.
1.5 Formatted input and output statements. Input and output function.
1.6 Operators and expressions:
a. Operators in ‘C’- arithmetic, logical, assignment, relational, increment and decrement, conditional, bit wise, special operators
b. Expressions
c. Precedence and associatively."
"2.1 Decision making if statement (if, if-else, nested if-else), switch –case statement.
2.2 Repetition in ‘C’ (loop control
statement) while, do-while and for loop, break and continue statement, nested loops
"
"3.1 Introduction to Array and its types
3.2 Declaration, initialization of array,
accessing elements of an array, adding,
deleting, sorting & searching.
3.3 Introduction to string Initializing,
declaring and display of string
3.4 String handling functions from standard library (strlen (), strcpy (), strcat (), strcmp(), strlwr(),strupr()):
"
"4.1 Concept and need of functions
4.2 Library functions: Math functions,
String handling functions, other
miscellaneous functions.
4.3 Writing User defined functions, scope of variables.
4.4 Parameter passing: call by value, call by reference.
4.5 Recursive functions
"
"5.1 Concept of pointer and pointer variables, initialization of pointer, call-by reference.
5.2 Pointer arithmetic.
5.3 Handling arrays using pointers
5.4 Handling functions using pointers
"
"6.1 Introduction and Features and Syntax of structure
6.2 Declaration and Initialization of
Structures
6.3 Initializing, assessing structure members using pointers
6.4 Type def, Enumerated Data Type,
using structures in C Program
6.5 Operations on structure."
#Code2Create series: C++ is a powerful general-purpose programming language. It can be used to develop operating systems, browsers, games, and so on. C++ supports different ways of programming like procedural, object-oriented, functional, and so on.Start your programming journey and join us to learn C++ basics!
by Google Developers Group and Women Tech-markers Kuwait chapter:
Instagram and Twitter: @GDGWTMKUWAIT
C programming_MSBTE_Diploma_Pranoti DokePranoti Doke
"1.1 Structure of ‘C’program, Assembler, Linker, Compiler, Interpreter.
1.2 ‘C’character set-keywords, identifiers, types of constants (Integer, single character, string, and real) variables, scope of variables, concept of ASCII.
1.3 Data types: integer- unsigned, signed, long, float- float, double, character char, string, octal, hexadecimal
1.4 Algorithm and flow chart.
1.5 Formatted input and output statements. Input and output function.
1.6 Operators and expressions:
a. Operators in ‘C’- arithmetic, logical, assignment, relational, increment and decrement, conditional, bit wise, special operators
b. Expressions
c. Precedence and associatively."
"2.1 Decision making if statement (if, if-else, nested if-else), switch –case statement.
2.2 Repetition in ‘C’ (loop control
statement) while, do-while and for loop, break and continue statement, nested loops
"
"3.1 Introduction to Array and its types
3.2 Declaration, initialization of array,
accessing elements of an array, adding,
deleting, sorting & searching.
3.3 Introduction to string Initializing,
declaring and display of string
3.4 String handling functions from standard library (strlen (), strcpy (), strcat (), strcmp(), strlwr(),strupr()):
"
"4.1 Concept and need of functions
4.2 Library functions: Math functions,
String handling functions, other
miscellaneous functions.
4.3 Writing User defined functions, scope of variables.
4.4 Parameter passing: call by value, call by reference.
4.5 Recursive functions
"
"5.1 Concept of pointer and pointer variables, initialization of pointer, call-by reference.
5.2 Pointer arithmetic.
5.3 Handling arrays using pointers
5.4 Handling functions using pointers
"
"6.1 Introduction and Features and Syntax of structure
6.2 Declaration and Initialization of
Structures
6.3 Initializing, assessing structure members using pointers
6.4 Type def, Enumerated Data Type,
using structures in C Program
6.5 Operations on structure."
SOME IMPORTANT TOPICS OF GROUP THEORY IN MODERN-1.pptxSONU KUMAR
CLOSURE PROPERTY, ASSOCIATIVE LAW,BINARY OPERATION, COMMUTATIVE LAW,DISTRIBUTIVE LAW IN GROUP THEORY, GROUP, NORMAL SUBGROUP, CONJUGATE NUMBER, SUBGROUP GROUP, ABELIAN GROUP AND THEIR APPLICATION
GROUP THEORY PPT,SUBGROUP, ABELIAN GROUP, SONU KUMAR
GROUP, SUBGROUP, ABELIAN GROUP, NORMAL SUBGROUP AND CONJUGATE NUMBER AND NORMALIZER OF A GROUP IN MODERN ALGEBRA,SOME IMPORTANT TOPICS OF GROUP THEORY IN MODERN ALGEBRA
0x01 - Newton's Third Law: Static vs. Dynamic AbusersOWASP Beja
f you offer a service on the web, odds are that someone will abuse it. Be it an API, a SaaS, a PaaS, or even a static website, someone somewhere will try to figure out a way to use it to their own needs. In this talk we'll compare measures that are effective against static attackers and how to battle a dynamic attacker who adapts to your counter-measures.
About the Speaker
===============
Diogo Sousa, Engineering Manager @ Canonical
An opinionated individual with an interest in cryptography and its intersection with secure software development.
This presentation by Morris Kleiner (University of Minnesota), was made during the discussion “Competition and Regulation in Professions and Occupations” held at the Working Party No. 2 on Competition and Regulation on 10 June 2024. More papers and presentations on the topic can be found out at oe.cd/crps.
This presentation was uploaded with the author’s consent.
Acorn Recovery: Restore IT infra within minutesIP ServerOne
Introducing Acorn Recovery as a Service, a simple, fast, and secure managed disaster recovery (DRaaS) by IP ServerOne. A DR solution that helps restore your IT infra within minutes.
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...Orkestra
UIIN Conference, Madrid, 27-29 May 2024
James Wilson, Orkestra and Deusto Business School
Emily Wise, Lund University
Madeline Smith, The Glasgow School of Art
Have you ever wondered how search works while visiting an e-commerce site, internal website, or searching through other types of online resources? Look no further than this informative session on the ways that taxonomies help end-users navigate the internet! Hear from taxonomists and other information professionals who have first-hand experience creating and working with taxonomies that aid in navigation, search, and discovery across a range of disciplines.
2. COMPUTER LANGUAGE
Language is the source of communication. In order to
communicate with computer, we also required a
language.
Computer
Language
1. Machine language
2. Assembly language
3. High livel language
3. 1. Machine language is
also known as "low
level languag" or
"Binary language".
2. In this language we
can use only "0 &1".
3. Modification is very
difficult.
4. No. Translation is
required
5. It is a machine
dependent language
MACHINE
LANGUAGE
ASSEMBLY
LANGUAGE
HIGH LEVEL LANGUAGE
1. It is also known as
''symbolic language"
2. In this language we
can use only (0-9)(a-
z) but we cannot use
any special
characters (@,#,+,%).
length of the word
should not be more
than 5 characters.
3. Modification is easy
4. Translator is requi-
red (Assembler).
5. It is also machine
dependent language.
4. 1. C is one of the most popular language designed and deceloped by Dennis
Ritchie in year 1992 at "AT &Y T" lab, US.
2. The concepts of C language are taken from B language BPCL (Basic
combined Programming Language).
3. It is machine independent.
4. C language follows the concept of structured programming.
OVER VIEW OF C LANGUAGE :-
PROPERTIES OF C LANGUAGE :-
1. C language supports newly 30 header files.
2. C language provides the facility to add any new function in
the header file.
3. C language supports 32 keywords.
4. C language has a rich set operation and data type.
5. C language also supports graphical programming.
5. 1. Every program should have main function.
2. Every statement should be properly terminated.
3. It is a case sensitive language.
4. No. of opening & closing bracket must be equal.
PROGRAMMING RULES :
Keywords :
1. Reserved words which we cannot use as a variable name
/ function name / array names are known as keywords.
2. C language supports 32 keywords.
auto
break
case
char
const
continue
default
do
double
else
enum
extern
float
for
go to
if
int
long
register
return
short
signed
size of
static
struct
switch
typed of
union
while
unsigne
d
void
6. IDENTIFIERS
:-
Array word/character which a user may use name as a variable name
/ function name / array name is called idetifiers.
Delimete
r :
Any symbol which a user may use in C programming language is
known as delimeter.
NAME SYMBOL WORK
Semicollon ; Used as a terminator to show the
end of statement.
Hash # Used as a pre
precessor.
Comma
parenthesis
Braces
Square Brackets
,
( )
{ }
[ ]
Used as a variable seperaor.
Used with every function.
Used to show the scope of function /
statement.
Used with Array.
7. TOKEN
Smallest unit of C programming language known as token.
Token
• Variables
• Constant
• Delimeter
• Keyword
• Indetifier
8. HEADER FILES :
• Header files are used at the top of program.
• Header files are collection of different function where
each function performs a unique task.
• C language supports 30 Header files
Example:-
1. <stdio.h>
• Standard Input / output Header files.
Function defined under <stdio.h.>
1. gets()
2. get c()
3. putc()
4. puts()
5. printf()
6.scanf()
9. 2. <conio.h>
• Ful form of <conio.h> is console input /output Header file.
• Function defined under <conio.h>
are -
1. clrscr()
2. getch()
3.<string.h>
• Functions defined <string.h> are -
1. strcpu()
2. strcat()
3. strlur()
4. strupr()
10. 4. <Math.h>
Functions defined under <math.h> are -
1. pow()
2. sqrt()
3. abs()
4. sin()
5. fmod()
5. <alloc.h>
1. calloc()
2. malloc()
3. realloc()
4. frec()
11. STRUCTURES OF A C PROGRAM :
Software Editor
Pre - Processor
Source code
compiler
Linker
Loader
Output
12. Execution of a C program : Source code in Editor
Pre processor
Compile Source Code
Syntax /
Editior
linking editior
Runtime
/logical error
Output
Input again
yes
yes
yes (logical
Error)
13. Data types
• It tells us nature of the data.
1. Primary Datatype
2. Secondary Datatype
3. User defined Datatype
char int float
double void function
Array pointer enum
structure union
14. Primary Datatypes
: FSTSTYPES RAMGE MEMORY
REQUIREMENT
FORMAT
SPECIFIER
Signed int -32768 to +32767 2 Bytes %d
unsigned int 0 to 65535 2 Bytes %u
short int -32768 to +32761 2 Bytes %d
long int -2147483648 to
+2147483647
4 Bytes %ld
signed char -128 to+127 1 Byte %c
float 3.4e^-38 to 3.4e^38 4 Byte %f
double 1.7e^-308 to 1.7e^38 8 Bytes %lf
void no return ___ ___
15. COMPUTER
"The oxford defines a computer as an automatic eletronic
operator for making calculation or controling operators that
are expressible in numerical or logical terms."
• Programs
Program is a set of instruction.
• Software
Software is a set of Programmes.
• System Software
System software is a software interface between system and
user. eg: All operating system (Window, linux.)
16. • Application
software
Other than system software all software are application software.
eg : Mcrosoft office, Whatsapp, Twitter, Oracle, Google
chrome.
• Basic Structure or design of computer
CPU
ALU MEMORY C.U
Memory or brain of computer
Input Output
• Input devices
keyword, mouse, joystic, lightpen, scanner
• Output device
monitor, printer, hard disk.
17. • CPU actually performs the 3C's :
1. Calcutate
2. compare
3. copy
Memory
On cheap memory (cache)
RAM/ROM
Primary memory
Secondary Memory
18. ALGORITHMS AND FLOWCHARTS
Program = Algorithms + Data
"An algorithim is an effective procedure for solving a problems in a
finite number of steps".
• Key features of an Algo :-
Algo having basically three features :-
1. Sequence ( also known as process )
2. Decision ( also known as selection )
3. Repeatation (also known as iteration or loop )
eg . for making a part of tea
19. VARIABLES : -
In previous Example tea making algo the level of water in a kettle
is variable. The temperature of water is a variable and quantity of
tea leaves is also a variable.
• Tea leaves -
quantity
• Water -
temperature
• Different ways of starting algo :-
1. Pseudo - code
2. flow - chart
Data Type
The data used to algo can be of different
types.
2. Alphabetic or Character data : R, A, V, I,
3. Logical Data : True, False
20. Write an algo for finding the sum of any two numbers.
1. START
2. PRINT "ENTER TWO NUMBERS".
3. INPUT "A & B"
4. C = A + B
5. PRINT C
6. STOP
Write an algo to print the
longest number among three
numbers.
1. START
2. PRINT "ENTER THREE
NUMBER"
3. INTPUT
4. IF A > B & A > C THEN,
PRINT A
5. ELSE B > A & B > C THEN ,
PRINT B.
6. PRINT C
7. STOP
21. FLOWCHART
Flowchart is appropriate step to be followed in order to arrive at
the solution to a problem.
Flowchart are generally developed in early stage of formulating
computer solution.
GUIDLINES FOR DRAWING OF FLOW CHART:-
Symbol are following :-
22. Symbol are following :-
Computational Step or Processing
Step
Input /Output
Decision making Step
For connection
Srart / End
23. Draw a flow chart to find the sum of first 10 numbers.
Start
Sum = 0
N =0
N =N+1
n =10
PRINT
STOP
1. N =0+1 = 1
SUM = 0+1 =1
2. N = 1+1 =2
SUM = 1+2 =3
3. N = 2+1 = 3
SUM = 3+3 = 6
4. N = 3+1 = 4
SUM = 6+4 = 10
.....................................
............................. so on
n=10
1. sum =0+1= 1
2. sum =1+2= 3
3. sum =3+3=6
4. sum =6+4 =10
5. sum= 10+5=15
6. sum =15+6=21
7. sum =21+7 =28
8. sum =28+8 =36
9. sum =36+9 =45
10. sum= 45+10
=55
24. Write a flowchart to find the largest among three numbers A, B, &
C.
start
Input A,B,C
Is B > C
?
Is A > B
?
Is A > C
?
Print B Print C Print A
Stop
yes yes yes
no
no no
25. Special Characters :-
, comma
. period or dot
; semicolumn
: colon
' apostrophe
" quotation mark
! exclamaton
| vertical bar
/ slash
back slash
~ tilde
_ under score
$ dollar
? question mark
& ampersand
^ caret
* asterisk
- minus
+ plus
< less than
> greater than
( ) parenthesis ;eft /right
[ ] bracket left /right
{} braces left /right
% percent
# number sign or hash
@ at the rate
26. • Printf :-
printf( ) is a function that is used to print any data on the
video monitor screen.
• It has the following form
printf(" control - string", list of variables)
• Control strings used for different data
types -- %c char
%d int
%u unsigned
%hd or %hi short int
%ld long int
%f float
%lf long float
%ld long double
29. Write a program of Arithmetic operation
#include<stdio.h>
#include<conio.h>
void main()
{
int a=100;
int b=2;
int c=25;
int d=4;
result=a+b;
printf("a+b=%dn", result);
result=a-b;
printf("a-b=%d n", result);
result=a*b;
printf("a*b=%d n", result);
result=a/b;
printf("a/b=%d n", result);
getch();
}
30.
31. #include<stdio.h>
#include<conio.h>
void main()
{
float A, r;
printf("Enter the value of radius r =");
scanf("%f", &r);
A=3.14*r*r;
printf("The area of given circle is %f" , A);
getch();
}
Write a program to calculate area of
circle
32. #include<stdio.h>
#include<conio.h>
void main()
{
int a, b, c;
priintf("n enter two numbers");
scanf("%d %d", &a,&b);
c=a;
a=b;
b=c;
printf("The answer is %d n",a,b);
getch();
}
Write a Program inc to swap the two integers
using third variable.
33. Write a program in c to swapping two numbers without using
third variables or without temporary variables.
34. #include<stsio.h>
#include<conio.h>
void main()
{
int a, b ;
printf("enter two numbers");
scanf("%d %d , &a,&b);
if(a>b)
printf("%d", a);
else,
printf("%d", b);
getch();
}
Write a program to read two numbers and then display the
larger out of these two numbers,
35. A statement is a systamtic construction that
performs a action when a program is executed.
IF - else :-
If r==0
printf|("r having no value");
else
priintf("r having same values");
36. Write a program in to check whether a number given by the
user is even or odd.
37. #include<stdio.h>
#include<conio.h>
void main ()
{
int n, r4, r100, r400;
printf("enter a number n");
scanf("%d", &n);
r4=n%4;
r100=n%100;
r400=n%400
if(r4==0 && r100!==0 || r400)
printf("year is leap year");
else
prinitf("It is not a leap year");
getch();
}
Write a program to determine a year is a
leap year.
39. #include<stdio.h>
#include<conio.h>
void main()
{
int x, y, z;
printf ("Enter three numbers");
scanf("%d%d%d", &x,&y,&z);
if(x<y)
if(x<z)
printf("x is the smallest");
else printf("z is smallest");
if(y<z)
printf("y is smallest);
else
printf("z is smallest");
getych();
}
Write a program to find the smallest number among three
numbers.
40. #include<stdio.h>
#include<conio.h>
void main()
{
int a, b, c, d;
printf("Enter four numbers");
scanf(%d%d%d%d", &a,&b,&c,&d);
if(a>b);
if(a>c);
if(a>d);
printf("a is the largest number);
else
printf("d is the largest number");
if(b>c)
If(b>d)
printf("b is the largest number");
else
printf("d is the largest number");
if(c>d)
printf("c is the largest number");
else
printf("d is the largest number");
Write a program to find largest number among four numbers.
41. A loop formed by using for statement is generally called definite loop because
the programmer knows exactly how many time it will repeat
FOR LOOP
The general form of statement is
as follows-
{
statement(s)
}
eg;
for(i=0; i<=n; i++)
42. #include<stdio.h>
#include<conio.h>
void main()
{
int i, sum=0, n.
printf("Enter the value of n");
scanf("%dn" &n);
for(i=0; i<=n; i++)
{
sum=sum+i;
}
printf("The value of sum", sum);
getch():
}
Write a program in c to find the sum of n numbers.
n=10
1. sum =0+1= 1
2. sum =1+2= 3
3. sum =3+3=6
4. sum =6+4 =10
5. sum= 10+5=15
6. sum =15+6=21
7. sum =21+7 =28
8. sum =28+8 =36
9. sum =36+9 =45
10. sum= 45+10 =55
43. Write a program to find factorial.
n =5
1. fact = 1*1
2. fact = 1*2
3. fact = 2*3
4. fact = 6*4
5. fact = 24*5 =120
44. Another construct that is very closely related to the
while construct is do-while constuct.
DO WHILE CONSTRUCTS
The form of this loop constuct is as follows :
{
//Body of statement
placed
}
while(condition)
46. When there are a number of else alternative, another way of
representing this multi way selection is by the switch statement.
SWITCH CASE SATEMENT :-
1. The switch structures is multi selection structure has allows the
handling of even more complicated decision statement, other than a
two way if-else statement. It chooses one of the cases depending on
the result of the expression.
2. One variable with int or char data type may be used in the expression,
sometime called the controlling expression of switch statement.
47. switch(expression)
{
case value 1:
program statement
--------------------------;
break;
case value 2:
program statement
-----------------------------;
break;
......
case value n:
program statement;
break;
default:
printf("Entry is invalid");
break;
}
The general format of switch statement is as follows -
48. Write a program to display the names of the days of a
week.
case 3:
printf("Day is tuesday");
break;
case 4:
printf("Day is wednesday")
break;
case 5:
printf("Day is thursday");
break;
case 6:
printf("Day is friday")
break;
case 7:
printf("Day is saturday");
break;
case 8:
printf("Entry is invalid");
break;
}
getch();
}
49. C is used the keyword if to execute the set of command lines
when the logical condittion is true.
The set of command lines are executed only one when
the logical condition is true.
IF STATEMENT
50. Write a program to check whether entered number is less
than 10 ? If yes, display the same.
#include<stdio.h>
#include<conio.h>
void main()
{
int i ;
clrscr();
printf("Enter the value you want to check :");
scanf("%d n", &i);
if(i<10)
printf("Entered value is <10");
getch();
}
51. Write a program to find Area of triangle using base and height.
#include<stdio.h>
#include<conio.h>
void main()
{
float base, height, area ;
printf("n Enter the base of a triangle ");
scanf("%f" , &base);
printf("n Enter the height of a triangle ");
sscanf"("%f", &height);
area=(base*height)/2;
printf("n The area of given triangle = %2fn" , area);
getch();
}
52. Write a c program to generate first n-prime numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int n, i=3, count, c ;
printf("How many prime numbers you want to
print :");
scanf("%d", &n);
printf('first n prime numbers are")
for(count=2; count<=n; count++)
{
for(c=2; c<=i-1; c++)
{
if(i%c==0)
break;
}
if(c==i)
printf("%dn", i);
count++;
}
i++;
}
return 0;
}
56. #include<stdio.h>
#include<math.h>
int is perfect (unsigned long log int n)
{
unsigned long long int dsum=0 ;
unsigned long long int i ;
for(i=1; i<=sqrt(n); ++i)
{
if(n%i==0)
{
if(i==n/i)
}
else
{
dsum=dsum+i;
Write a program to generate first n perfect number.
dsum=dsum+n/i;
}
}
}
dsum=dsum-n;
if(dsum==n)
return 1;
else
return 0;
}
57. int main()
{
unsigned long long int n, i,temp;
printf("Enter n ");
scanf("%llu", &n);
i=1;
while(n>0)
{
if(is perfect(i)==1)
printf("%llu", i);
n=n-1;
}
i=i+1;
return 0;
}
58. Write a c program to evaluate sinx and cosx up to n terms
using Taylor's series.
#include<stdio.h>
#include<sonio.h>
void main()
{
int i, n;
float x, sum_cos=1, sum_sin, t=1;
printf("Enter the value of x");
scanf("%f, &x);
printf("Enter the llimit t /term to which series should be
evaluated);
scanf("%d", &n);
x=x*8.14159/180;
/*loop to calculate value of cos in series */
60. Write a Program in c to print addition & multiplication of two
matrices of order m*n.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10][10], b[10][10], c[10][10], m, n, i, j ;
printf("Enter the value of row m and column n of matrices");
scanf("%d%d", &m,&n);
printf("Enter the element of matrix a");
for(i=0; i<=(m-1); i=i+1)
{
for(j=0; j<=(n-1); j++)
{
scanf("%d", &a[i][j]);
}}
61. printf("Enter the element of matrix b");
for(i=0; i<=(m-1); i++)
{
for(j=0; j<=(m-10); j=j+1)
{
scanf("%a", &b[i][j]);
}}
printf("matrix a is n");
for(i=0; i<=(m-1); i+1)
{
for(j=0; j<=(n-1); j+1)
{
printf("dt", a[i][j]);
}
printf("n");
}
printf("matrix b is n");
for(i=0; i<=(m-1); j=j+1)
{
for(j=0; j<=(n-1); j=j+1)
{
printf("%dt", b[i][j]);
63. Write a program in c to print Transpose of a matrix of order
n*n.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10][10], n, m,i, j ;
printf("Emter value of row m & colum n : ");
scanf("%d%d", &m, &n);
printf("Enter the element of matrix a : ");
for(i=0; i<=(m+1); i++)
{
for(j=0; j<=(n-1); j=j+1
{
scanf("%d", &a[i][j]);
}}
67. QUESTION BANK QUESTIONS
Write a program to take a five digits number and find the sum
of the digit of the number.
#include<stdioi.h>
#inclulde<conio.h>
void main()
{
int n, r, sum=0 ;
priintf("Enter the number of five digits");
scanf("%d", &n);
while(n>0)
{
r=n%10;
sum=sum+r;
n=n=n/10;
}
printf("sum of digits = %d", sum);
getch();
}
68. Write a program to find the product of two
matrices.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[2][2], b[2][2], c[2][2], i, j, k, sum;
printf("Enter four values for 1st matrix'');
for(i=0; i<2; i++)
{
for(j=0; f<2; j++)
scanf("%d", &a[i][j]);
}
printf("Enter four values for 2nd matrix'');
for(i=0; i<2; i++)
{
for(j=0; j<2; j++)
{
scanf("%d", &b[i][j]);
}}
for(i=0; i<2; i++0)
{
for(j=0; j<2; j++)
{
sum=0;
}
for(k=0; k<2; k++)
{
sum=sum+a[i[]k]*b[k][i];
c[i][j] = sum;
}}
printf("product of matrix is ");
for(i=0; i<2; i++)
{
for("j=0; j<2; j++);
printf("%dt", c[i][j]);
printf("n");
}
getch();
}
69. What is union? How it differs from structure?
Definition of union
A union is a user defined type in which all members share the same memory location,
this means that at any given time a union can contain no more than one object from
its list of members. It also means that no matter how many members a union has. It
always uses only enouygh memory to share the largest member.
Differnnce between union and structure
Strucfture
1. The keyword struct is used to defined
a structure.
2. When a variable is associate with a
structure the compiler allocates the
memory for each member. The size of
structure is greater than or equal to
sum of sizes ofits member.
3. Each member with a structure is
assigned uniquestrange area of
location
Union
1. The keyword union is used to defined union.
2. When a variable is associated with a union the
compiler allocates the memory by
considering size of the largest memory. So
size of union is equal to size of largest
member.
3. Memory allocation is shared by individuals a
member if union.
4. Altering the values of any of the member will
alter other member values.
70. 4. Altering the value of a member will not
alter other members of the structre.
5. Individual member can be accessed at
a time.
6. Several members of a structure can
initialize at once.
5. Only one member can be accessed at
a time.
6. Only the first member of a union can
be initialize.
Write the difference between logical operator and Bitwise
operator.
Bitwise operator
1. Its symbol is '&'.
2. It evaluates both left and right
side of expression.
3. It operates on "Boolean data
type " as well as operates on
"bits".
4. It use to check logical condition
and also used to mask offcertain
bits such as parity bits.
Logical operators
1. Its symbol is '&&'.
2. Its only evaluates the left side of
the expression.
3. It operates only on "Boolean
datatypes".
4. It uses to only check.
71.
72. What is recursion? What are its advantages? How it is excuted.
Explain with the help of an example.
A recursive function is a function that calls itself to perform a
specific operation. The process of a function calling itself is
known as recursion.
In other word, A function is called recursive when it
calls itself there is always if statement in recursive function
to force the function to return without recursive call being
exacated otherwise the function goes in indefinite loop.
Advantages of recursion:-
Through recursion we can solve the problem in easy way
while its interative solution is very big and complex. It is
useful to step through the function observing what value
gets returned with each call.
73. Execution with example :-
Recursion in C for factorial -
#include<stdio.h>
#include<conio.h>
int fact(int);
void main()
{
int n; int res;
priintf("Enter a numner");
scanf("%d", &n);
res=fact(n);
printf("factorial is =%d", res);
}
int fact(int x)
{
int f:
if(x==1)
return(1);
else
f=x*fact(x-1);
return(f);
}
74. What is looping ? Explain the syntax of while loop by taking an
example.
Looping :-
Looping is a concept that is applied in programming in general. It
is the way to execute a set of instructions any number of times.
In C the loopiing concept can be applied using -
1. While loop
2. Do - while loop
3. Go to sattement.
While loop is also known as entry controlled loop as the condition
to be checked is given before the statements that are to be
iterated.
Syntax for a while loop is -