ZOHO BASED BASICS CODE QUESTIONS
CAREER PREP GROUP - U1 AHM AASHA
1. Write a C program to find out the Greatest of Three Numbers
Ans : #include <stdio.h>
int main() {
double num1, num2, num3;
printf("Enter first number: ");
scanf("%lf", &num1);
printf("Enter second number: ");
scanf("%lf", &num2);
printf("Enter third number: ");
scanf("%lf", &num3);
// if num1 is greater than num2 & num3, num1 is the largest
if (num1 >= num2 && num1 >= num3)
printf("%lf is the largest number.", num1);
// if num2 is greater than num1 & num3, num2 is the largest
if (num2 >= num1 && num2 >= num3)
printf("%lf is the largest number.", num2);
// if num3 is greater than num1 & num2, num3 is the largest
if (num3 >= num1 && num3 >= num2)
printf("%lf is the largest number.", num3);
return 0;}
Output:
2. Write a C program to find out the Area and Circumference of Circle
Ans : C Program to find area and circumference of circle
1 #include<stdio.h>
2
3 int main() {
4
5 int rad;
6 float PI = 3.14, area, ci;
7
8 printf("\nEnter radius of circle: ");
9 scanf("%d", &rad);
10
11 area = PI * rad * rad;
12 printf("\nArea of circle : %f ", area);
13
14 ci = 2 * PI * rad;
15 printf("\nCircumference : %f ", ci);
16
17 return (0);
18 }
Output :
1 Enter radius of a circle : 1
2 Area of circle : 3.14
3 Circumference : 6.28
3. Write a C program to find out the Average of three Real
Numbers
Ans: C program to compute the average of three
given numbers.
C Program
. #include <stdio.h>
. #include <conio.h>
. void main()
. {
. int n1,n2,n3;
. float avg;
. clrscr();
. printf("\nENTER THREE NUMBERS: " );
. scanf("%d %d %d",&n1,&n2,&n3);
. avg=(n1+n2+n3)/3;
. printf("\nAVERAGE: %0.2f",avg);
. getch();
. }
Output
4. Write a C program to find out the Sum of two Numbers
Program : C Program to find sum of two numbers
1 #include<stdio.h>
2
3 int main() {
4 int a, b, sum;
5
6 printf("\nEnter two no: ");
7 scanf("%d %d", &a, &b);
8
9 sum = a + b;
10
11 printf("Sum : %d", sum);
12
13 return(0);
14 }
Output :
1 Enter two no: 5 6
2 Sum : 11
5. Write a C program to convert Hour into Minutes
Ans: #include <stdio.h>
int main(void) {
int hours;
printf("Please enter hours:");
scanf("%d", &hours);
int minutes = hours * 60;
printf("%d Minutes", minutes);
}
Output:
Please enter hours: 12
720 Minutes
6. Write a C program to find out the Simple Interest
Ans: #include <stdio.h>
int main(){
float principle, time, rate, SI;
/* Input principle, rate and time */
printf("Enter principle (amount): ");
scanf("%f", &principle);
printf("Enter time: ");
scanf("%f", &time);
printf("Enter rate: ");
scanf("%f", &rate);
/* Calculate simple interest */
SI = (principle * time * rate) / 100;
/* Print the resultant value of SI */
printf("Simple Interest = %f", SI);
return 0;}
Output
Enter principle (amount): 1200
Enter time: 2
Enter rate: 5.4
Simple Interest = 129.600006
7. Write a C program to convert Celsius to Fahrenheit
8. Write a C program to find out the Area and Perimeter of
Rectangle
Ans:#include<stdio.h>//function to calculate areaint area(int a, int b) {
int area = a * b;
return area;}//function to calculate perimeterint perimeter(int a, int b){
int perimeter = 2*(a + b);
return perimeter;}int main(){
int length= 20;
int breadth = 30;
printf("area of rectangle is : %d\n",area(length,breadth));
printf("perimeter of rectangle is : %d",perimeter(length, breadth));
return 0;}
Output
area of rectangle is : 600
perimeter of rectangle is : 100
9. Write a C program to find out the Area and Perimeter of Square
Ans:
10. Write a C program to find out the Sum and Percentage of five Marks
11. Write a C program for Swapping two Values without Using
Temporary Variables
12. Write a C program for Swapping two values Using Temporary
Variable
13. Write a C program to check the given year is Leap Year or not
14. Write a C program to check whether the person is eligible to Vote or
Not
15. Write a C program to find out the given number is Greater than100 or
Not
16. Write a C program to find out the bigger of two Numbers
17. Write a C program to find out the given number is Odd or Even
Number
18. Write a C program to convert Fahrenheit to Celsius
19. Write a C program to find out the Greatest of two Numbers Using
Conditional Operator
20. Write a C program to find the root of a Quadratic equation