forked from DAN-329/C_to_Python_translator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc-program.txt
71 lines (71 loc) · 1.06 KB
/
c-program.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include<stdio.h>
#include<string.h>
#include<math.h>
void work(int i)
{
while(i<10)
{
printf("The value of i is %d\n",i);
i++;
}
}
void work2(int num)
{
int sum;
sum=0;
for(int k=0;k<num;k++)
{
sum+=k;
}
printf("The sum is %d\n",sum);
}
int main()
{
int i,a,b,num;
char name[10],ch;
int arr1[10];
int arr2[]={1,2,3,4,5,6,7,8,9};
printf("Enter your name\n");
scanf("%s",&name);
printf("Enter a or b or c\n");
scanf("%c",&ch);
switch(ch)
{
case 'a':
printf("The letter is %c\n",ch);
break;
case 'b':
printf("The letter is %c\n",ch);
break;
case 'c':
printf("The letter is %c\n",ch);
break;
default:
printf("Invalid input\n");
break;
}
printf("Enter the value of i\n");
work(i);
printf("Enter values of a and b\n");
scanf("%d",&a);
scanf("%d",&b);
if(a>b)
{
printf("a is bigger\n");
}
else
{
printf("b is bigger\n");
}
printf("Enter the value of j\n");
scanf("%d",&j);
do
{
printf("The value of j is %d\n",j);
j++;
}while(j<10);
printf("Enter a number\n");
scanf("%d",&num);
work2(num);
return 0;
}