0% found this document useful (0 votes)
26 views

C Programming For Linear Search and Calculator

The document shows a C program that takes in two numbers from a user, asks the user to select an arithmetic operator, performs the calculation, and displays the result. It includes taking in the numbers, a switch statement to handle the operator, performing the calculation, and printing out the final result. The program runs and prompts the user to enter values and displays the output.

Uploaded by

Shubham G
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

C Programming For Linear Search and Calculator

The document shows a C program that takes in two numbers from a user, asks the user to select an arithmetic operator, performs the calculation, and displays the result. It includes taking in the numbers, a switch statement to handle the operator, performing the calculation, and printing out the final result. The program runs and prompts the user to enter values and displays the output.

Uploaded by

Shubham G
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Enter first number: 56

Enter second number: 44


Choose operation to perform (+, -,*,/,):
+

Result: 56 4 4 = 100.000000

[Process complleted press Enter]

1 2 3 4 5 67 8 9
%
W e ty ui
# &

as d f h

zxcvbn m
10:02 Ye 35

Coding C RUN MENU


Auto saved at 22:02:30

11 printf("Enter second number: ");


12 scanf("%d" , &num2);
13
14 printf("Choose operation to perform
15 Scanf(" %c" ,&ch);
16
17 result=0;
18 switch(ch)
19
20 case '+
21 result=num1+num2;
22 break;
23
24 Case

25 result=num1 -num2;
26 break;
27
28 case *
29 result=num1*num2;
30 break;
31
32 case '/':
33 result=(float)num1/(float)nu
34
35
break;
36 case %
37 result=num1%num2;
38 break;
39 default:
40 printf("Invalid operation. \n
41
42
43 printf("Result: %d %c %d = %f\n" , num
44 return 0;
45}
Tab

&

=
#include <stdi0. h>
int main()

int array[ 100], search, C, n;

printf("Enter number of elements in ar

scanf("%d", &n);

printf("Enter %d integer(s)\n", n);

for (c 0; C < n; C+*))


=

Scanf("%d", &array[c]);
printf("Enter a number to search\n");
scanf("%d", &search);
for (c =
0; c <
n; ct+)
if (array[c] == search) /* If req

printf("%d is present at location


break;

i f (c == n)
printf("%d isn't present in the arram
return 0;
Enter number of elements in array
6
Enter 6 integer(s)
10
20
33
40
50
67
Enter a number to search
40
40 is present at location 4.

[Process completed - press Enter]

1 2 3 4 5 67 89 0
%

a
W
s
e
d
r
f
t
yuiop
& k

zxcvbn m

You might also like