Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Karansankhe authored Jun 1, 2022
1 parent a6cfc4b commit d531a3b
Show file tree
Hide file tree
Showing 13 changed files with 339 additions and 0 deletions.
84 changes: 84 additions & 0 deletions 2d arrays.txt
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
27 changes: 27 additions & 0 deletions FC 1.txt
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
12 changes: 12 additions & 0 deletions arrays.txt
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
32 changes: 32 additions & 0 deletions fc 2.txt
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
25 changes: 25 additions & 0 deletions log opertaors.txt
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
27 changes: 27 additions & 0 deletions loops a.txt
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
28 changes: 28 additions & 0 deletions loops b.txt
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
21 changes: 21 additions & 0 deletions pointers.txt
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 = &num;

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
16 changes: 16 additions & 0 deletions slf2.txt
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
17 changes: 17 additions & 0 deletions slf3.txt
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
16 changes: 16 additions & 0 deletions str1.txt
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
12 changes: 12 additions & 0 deletions str2.txt
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
22 changes: 22 additions & 0 deletions working with structures.txt
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

0 comments on commit d531a3b

Please sign in to comment.