-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6cfc4b
commit d531a3b
Showing
13 changed files
with
339 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#include <stdio.h> | ||
|
||
int main() | ||
{ | ||
int i,j; | ||
int num1[3][4],num2 [3][4]; | ||
printf("Enter the elements of 3x4 array num1\n"); | ||
for(i=0;i<3;i++) | ||
for(j=0;j<4;j++) | ||
scanf("%d", &num1 [i][j]); | ||
|
||
printf("Enter the elements of 3x4 array num2\n"); | ||
for(i=0;i<3;i++) | ||
for(j=0;j<4;j++) | ||
scanf("%d", &num2 [i][j]); | ||
|
||
printf("The 3x4 array num1 is\n"); | ||
for(i=0;i<3;i++) | ||
{ | ||
for(j=0;j<4;j++) | ||
printf ("%3d", num1[i][j]); | ||
printf("\n"); | ||
} | ||
printf("The 3x4 array num2 is\n"); | ||
for(i=0;i<3;i++) | ||
{ | ||
for(j=0;j<4;j++) | ||
printf ("%3d", num2[i][j]); | ||
printf("\n"); | ||
} | ||
|
||
printf("The sum of num1 and num2 is\n"); | ||
for (i=0;i<3;i++) | ||
{ | ||
for (j=0;j<4;j++) | ||
printf("%3d",(num1[i][j] + num2[i][j])); | ||
printf("\n"); | ||
} | ||
return 0; | ||
} | ||
|
||
|
||
|
||
Output- | ||
|
||
Enter the elements of 3x4 array num1 | ||
1 | ||
2 | ||
3 | ||
4 | ||
5 | ||
6 | ||
7 | ||
8 | ||
9 | ||
10 | ||
11 | ||
12 | ||
Enter the elements of 3x4 array num2 | ||
13 | ||
1 | ||
4 | ||
5 | ||
6 | ||
8 | ||
9 | ||
10 | ||
22 | ||
15 | ||
16 | ||
17 | ||
18 | ||
The 3x4 array num1 is | ||
1 2 3 4 | ||
5 6 7 8 | ||
9 10 11 12 | ||
The 3x4 array num2 is | ||
13 1 5 6 | ||
8 9 10 22 | ||
15 16 17 18 | ||
The sum of num1 and num2 is | ||
14 3 8 10 | ||
13 15 17 30 | ||
24 26 28 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include<stdio.h> | ||
|
||
int cube(int z) | ||
|
||
{ | ||
|
||
z=z*z*z; | ||
|
||
return(z); | ||
|
||
|
||
} | ||
|
||
int main() | ||
|
||
{ | ||
|
||
int n=99; | ||
|
||
printf("Cube of %d is %d\n",n,cube(n)); | ||
|
||
return 0; | ||
|
||
} | ||
|
||
Output- | ||
Cube of 99 is 970299 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include<stdio.h> | ||
int main() | ||
{ | ||
int star[3]={4,5,6}; | ||
int sum; | ||
sum=star[0]+star[1]+star[2]; | ||
printf("The sum is %d\n",sum); | ||
return 0; | ||
} | ||
|
||
Output- | ||
The sum is 15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
int swap (int*a, int*b) | ||
{ | ||
int t; | ||
t=*a; | ||
*a=*b; | ||
*b=t; | ||
} | ||
int main() | ||
{ | ||
int i,j; | ||
printf("Enter the values : \n"); | ||
scanf("%d %d" ,&i,&j); | ||
|
||
printf("Before swapping %d and %d\n",i,j); | ||
swap (&i,&j); | ||
|
||
printf("Ater swapping %d and %d\n" ,i,j); | ||
|
||
return 0; | ||
} | ||
|
||
|
||
|
||
Output- | ||
Enter the values : | ||
10 | ||
11 | ||
Before swapping 10 and 11 | ||
Ater swapping 11 and 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
#include<stdio.h> | ||
int main() | ||
{ | ||
int a,b,c; | ||
printf("Enter the values of a, b and c\n"); | ||
scanf(" %d %d %d", &a, &b, &c); | ||
if ((a>b) && (a>c)) | ||
printf("a is greatest\n"); | ||
else if (b > c) | ||
printf("b is greatest\n"); | ||
else | ||
printf("c is greatest\n"); | ||
if ((a==0)||(b==0)||(c==0)) | ||
printf("The product of a, b and c is zero\n"); | ||
return 0; | ||
} | ||
|
||
|
||
Output- | ||
Enter the values of a, b and c | ||
7 | ||
6 | ||
2 | ||
a is greatest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include<stdio.h> | ||
int main() | ||
{ | ||
int x=0; | ||
int y=0; | ||
while (x<=10) | ||
{ | ||
y=y+x; | ||
printf("%d\n",y); | ||
x++; | ||
} | ||
} | ||
|
||
|
||
|
||
Output- | ||
0 | ||
1 | ||
3 | ||
6 | ||
10 | ||
15 | ||
21 | ||
28 | ||
36 | ||
45 | ||
55 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include<stdio.h> | ||
int main() | ||
{ | ||
int x=0; | ||
int y=0; | ||
do | ||
{ | ||
y=y+x; | ||
printf("%d\n",y); | ||
x++; | ||
} | ||
while (x<=10); | ||
return 0 ; | ||
} | ||
|
||
Output: | ||
|
||
0 | ||
1 | ||
3 | ||
6 | ||
10 | ||
15 | ||
21 | ||
28 | ||
36 | ||
45 | ||
55 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <string.h> | ||
void main() | ||
{ | ||
long int num = 7; | ||
long int *ptr; | ||
printf ("num's address : %p\n",&num); | ||
ptr = # | ||
|
||
printf ("pointer's address : %p\n",&ptr); | ||
printf ("pointer's size : %ld bytes\n",sizeof(ptr)); | ||
printf ("pointer's value : %p\n", ptr); | ||
printf ("Value pointed to : %ld\n", *ptr); | ||
|
||
} | ||
|
||
|
||
Output- | ||
pointer's address : 0x7ffe4e327450 | ||
pointer's size : 8 bytes | ||
pointer's value : 0x7ffe4e327448 | ||
Value pointed to : 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <stdio.h> | ||
#include<string.h> | ||
int main() | ||
{ | ||
char source[]="karan"; | ||
char target[10]; | ||
strcpy(target,source); | ||
printf("source string=%s\n",source); | ||
printf("target string=%s\n",target); | ||
|
||
return 0; | ||
} | ||
|
||
Output- | ||
source string=karan | ||
target string=karan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include<stdio.h> | ||
#include<string.h> | ||
int main() | ||
{ | ||
char str1[]="Ice"; | ||
char str2[]="Cream"; | ||
int i,j; | ||
i = strcmp(str1,"Hello"); | ||
j = strcmp(str2,"Cream"); | ||
printf("%d,%d\n",i,j); | ||
|
||
return 0; | ||
} | ||
|
||
|
||
Output- | ||
1,0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include<stdio.h> | ||
#include<string.h> | ||
int main() | ||
{ | ||
char strname [40]; | ||
printf ("Enter the string\n"); | ||
scanf("%[^\n]s" , strname); | ||
printf ("The string is %s\n", strname); | ||
return 0; | ||
} | ||
|
||
|
||
Output- | ||
Enter the string | ||
k | ||
The string is k |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include<stdio.h> | ||
#include<string.h> | ||
int main() | ||
{ | ||
char strname [40]= "karan sankhe"; | ||
printf ("The string is %s\n", strname); | ||
return 0; | ||
} | ||
|
||
|
||
Output- | ||
The string is karan sankhe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <stdio.h> | ||
struct student | ||
{ | ||
int phy; | ||
int maths; | ||
int CP; | ||
}; | ||
int main () | ||
{ | ||
int total; | ||
struct student stud; | ||
stud.phy=100; | ||
stud.maths=100; | ||
stud.CP=100; | ||
total= stud.phy + stud.maths+stud.CP; | ||
printf("The total is %d\n",total); | ||
return 0 ; | ||
} | ||
|
||
|
||
Output- | ||
The total is 300 |