-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay2 Assign.txt
55 lines (38 loc) · 1.19 KB
/
Day2 Assign.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
DAY 2 ASSIGNMENT
1)
#include<stdio.h>
#include<conio.h>
int main(){
int i,j;
for(i=1;i<=4;i++){
for(j=1;j<=((2*i)-1);j++){
if(j%2!=0) printf("%d",i);
else printf("*");
}
printf("\n");
}
return 0;
}
===========================================================================
2)
#include<stdio.h>
#include<conio.h>
int main(){
int i,j;
for(i=1;i<=5;i++){
for(j=1;j<=i;j++){
if((i%2==0 && j%2==0) || (i%2!=0 && j%2!=0)) printf("1");
else printf("0");
}
printf("\n");
}
return 0;
}
=============================================================================
3)
SIMILARITIES:
> Both array name and pointer variable store the address of another variables.
> In case of array, it stores the address of its first elemenet(at index 0).
DIFFERENCES:
> Using array name, whole array can be accessed but using pointer variable only one element can be accessed.
> sizeof() operator returns size of array in case of array name whereas size of int in case of pointer variable.