5. main
stdio.h
#include <stdio.h>
int int main()
{
int a, b, sum;
printf() printf("Enter A: "); int
scanf("%d", &a); a, b sum
printf("Enter B: ");
scanf("%d", &b); scanf()
sum = a+b;
printf("Sum = %dn", sum);
getch();
return 0;
}
0
;
5
12. C
auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof while do
12
19. •
• printf
int c = 65; :
2
printf("c (as a number) = %dn", c);
30
printf("c (as a character) = %cn", c);
65 c
5
: 8
c (as a number) = 65 23
c (as a character) = A :
19
20. %format scanf
printf
%for
mat
int %d
long %ld
long long %lld
unsigned int %u
unsigned long %lu
unsigned long long %llu
float %f
double %lf
char %c
char array[] %s
20
21. scanf
char name[20];
int age;
printf("Enter your name and age: ");
scanf("%s %d", name, &age);
printf("Hello %s. You are %d years old.n",
name, age);
:
Enter your name and age: Tony 38
Hello Tony. You are 38 years old.
21
22. •
START
Statement1
Statement2
START
Statement3
Statement
END Statementn
END
22
27. AND Operators
•
A B A && B
True True T && T True 1
True False T && F False 0
False True F && T False 0
False False F && F False 0
27
28. AND Operators
• AND Operators
i = 8; j = 4.5; k = „z‟; // ascii z 122
Expression
(i >= 6) && (k == „z‟) T && T == T 1
(i >= 6) && (k == 122) T && T == T 1
(j >= 0) && (j != 4.5) T && F == F 0
(k > 0) && (j != 5) T && T == T 1
(i < 0) && (j > 0) && (k > 0) F && T && T == 0
F
28
29. OR Operators
•
A B A || B
True True T || T True 1
True False T || F True 1
False True F || T True 1
False False F || F False 0
29
30. OR Operators
• OR Operators
i = 8; j = 4.5; k = „z‟; // ascii z 122
Expression
(i >= 6) || (k == „z‟) T || T == T 1
(i >= 6) || (k != 122) T || F == T 1
(j < 0) || (j != 4.5) F || F == F 0
(k > 0) || (j != 5) T || T == T 1
30
57. • void say_hi(char *name)
{
printf("Hi, %sn", name);
void }
return
int max(int a, int b)
{
• if (a > b)
return a;
else
return b;
}
return
57
58. #include <stdio.h>
int incr(int i)
{
int j;
function1.c
j = i + 1;
return j;
}
int main()
{
int k, m = 4;
k = incr(m);
printf ("k = %d, m = %dn", k, m);
getch();
return 0;
}
58