Skip to content

Commit bd257ff

Browse files
authored
Add files via upload
1 parent 91697ff commit bd257ff

File tree

5 files changed

+210
-0
lines changed

5 files changed

+210
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Your job is to create number of nodes as per user request using pointer
3+
4
4+
1 4 5 99
5+
1 4 5 99
6+
5
7+
1 4 5 99 100
8+
1 4 5 99 100
9+
2
10+
1 4
11+
1 4
12+
13+
*/
14+
#include<stdio.h>
15+
#include<stdlib.h>
16+
int main ()
17+
{
18+
int *p,i,no;
19+
scanf("%d",&no);
20+
p = (int *)malloc (no*sizeof(int));
21+
for (i=0;i<no;i++)
22+
scanf("%d",p+i);
23+
for (i=0;i<no;i++)
24+
{
25+
printf("%d ",*p);
26+
p++;
27+
}
28+
return 0;
29+
}
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*Bob was bored that day, so she was sitting on the riverbank .Suddenly she notices a talking, White Rabbit with a pocket watch .It ran fast, and she followed it, down a rabbit hole .She fell into the hole and found a magical wonderland with dark trees, beautiful flowers.She found many ways numbered from 1,2,3,........18.she was confused which is the right way that will lead her to her home. She found a cute bird, standing in one of the tree. Alice asked the bird the way to go back to her home.The bird said a two digit number( say 23 ) and asked her to find the sum of its digits (2+3=5) and that numbered way will lead her to her home.Alice was already confused, so pls help Alice in finding the route to her home....
2+
3+
Input Format:
4+
Input consists of an integer corresponding to the 2-digit number.
5+
Output Format:
6+
Output consists of an integer corresponding to the sum of its digits. Refer sample input and output for formatting specifications.
7+
8+
[All text in bold corresponds to input and the rest corresponds to output]
9+
TEST CASE 1
10+
11+
INPUT
12+
23
13+
OUTPUT
14+
Bob must go in path-5 to find her way to home
15+
TEST CASE 2
16+
17+
INPUT
18+
99
19+
OUTPUT
20+
Bob must go in path-18 to find her way to home
21+
*/
22+
23+
#include <stdio.h>
24+
int main() {
25+
int no,a,b,c;
26+
scanf("%d",&no);
27+
a=no/10;
28+
b=no%10;
29+
c=-a-b;
30+
printf("Bob must go in path%d to find her way to home",c);
31+
return 0;
32+
}
33+
--------------------------------------------------------------
34+
35+
#include <stdio.h>
36+
37+
int main()
38+
{
39+
int num, temp, digit, sum = 0;
40+
41+
42+
scanf("%d", &num);
43+
temp = num;
44+
while (num > 0)
45+
{
46+
digit = num % 10;
47+
sum = sum + digit;
48+
num /= 10;
49+
}
50+
printf("Bob must go in path-%d to find her way to home",sum);
51+
return 0;
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*Write a program to find sum of n elements entered by user. To perform this program, allocate memory dynamically using malloc() function
2+
TEST CASE 1
3+
4+
INPUT
5+
5
6+
1 2 3 4 5
7+
OUTPUT
8+
Sum=15
9+
TEST CASE 2
10+
11+
INPUT
12+
7
13+
5 5 5 5 5 1 1
14+
OUTPUT
15+
Sum=27
16+
*/
17+
#include<stdio.h>
18+
#include<stdlib.h>
19+
int main ()
20+
{
21+
int i,no,*p,sum=0;
22+
scanf("%d",&no);
23+
p= (int * ) malloc (no*sizeof(int));
24+
25+
for (i=0;i<=no;i++)
26+
{
27+
scanf("%d",p+i);
28+
}
29+
for(i=0;i<no;i++){
30+
sum=sum+*p;
31+
p++;
32+
}
33+
printf("Sum=%d",sum);
34+
return 0;
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*Rahul and Ram played a game of exchanging their pocket money on a holiday. Rahul tries to give his pocket money to Ram and get Ram's pocket money.
2+
Both of them were strucking in to solve the problem. You help them to solve the problem
3+
TEST CASE 1
4+
5+
INPUT
6+
5 4
7+
OUTPUT
8+
x=5
9+
y=4
10+
After Swapping
11+
x=4
12+
y=5
13+
TEST CASE 2
14+
15+
INPUT
16+
100 239
17+
OUTPUT
18+
x=100
19+
y=239
20+
After Swapping
21+
x=239
22+
y=100
23+
*/
24+
#include<iostream>
25+
using namespace std;
26+
int main ()
27+
{
28+
int *a,*b,temp,x,y;
29+
scanf("%d%d",&x,&y);
30+
printf("x=%d\ny=%d\n",x,y);
31+
32+
a=&x;// a assign to x
33+
b=&y;// b assign to y
34+
35+
temp=*a;
36+
*a=*b;
37+
*b=temp;
38+
printf("After Swapping\n");
39+
printf("x=%d\ny=%d\n",x,y);
40+
return 0;
41+
}
42+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
In olden days finding square roots seemed to be difficult but nowadays it can be easily done using in-built functions available across many languages .
3+
4+
Assume that you happen to hear the above words and you want to give a try in finding the square root of any given integer using in-built functions. So here's your chance.
5+
Input
6+
7+
The first line of the input contains an integer T, the number of test cases. T lines follow. Each T contains an integer N whose square root needs to be computed.
8+
Output
9+
10+
For each line of input output the square root of the input integer.
11+
Constraints
12+
13+
1<=T<=20
14+
1<=N<=10000
15+
TEST CASE 1
16+
17+
INPUT
18+
3
19+
10
20+
5
21+
10000
22+
OUTPUT
23+
3
24+
2
25+
100
26+
TEST CASE 2
27+
28+
INPUT
29+
1
30+
10
31+
OUTPUT
32+
3
33+
*/
34+
35+
#include <stdio.h>
36+
#include<stdlib.h>
37+
#include<math.h>
38+
int main() {
39+
int no,*p,i,a;
40+
scanf("%d",&no);
41+
p=(int *)malloc(no*sizeof(int));
42+
for (i=0;i<no;i++){
43+
44+
scanf("%d",p+i);
45+
}
46+
for(i=0;i<no;i++){
47+
a=sqrt(*p);
48+
p++;
49+
printf("%d\n",a);
50+
}note
51+
return 0;
52+
}

0 commit comments

Comments
 (0)