C ASSIGNMENT ALL
C ASSIGNMENT ALL
h>
int main()
{
int a;
printf("enter the value of a ");
scanf("%d",&a);
if(a>10){
printf("number is greater than 10");
}
return 0;
}
2. #include <stdio.h>
int main()
{
int a;
printf("enter the value of a ");
scanf("%d",&a);
if(a>10){
printf("number is greater than 50");
}
return 0;
}
3. #include <stdio.h>
int main()
{
int a;
printf("enter the value of a ");
scanf("%d",&a);
if(a>10){
printf("number is greater than 87");
}
return 0;
}
4. int main()
{
int a;
printf("enter the value of a ");
scanf("%d",&a);
if(a==1){
printf("one");
}
else{
printf("your input is not valid ");
}
return 0;
}
6.#include <stdio.h>
int main()
{
char a;
printf("enter the character");
scanf("%c",&a);
if(a=='a'){
printf("apple");
}
else{
printf("your input is not valid ");
}
return 0;
}
7.#include <stdio.h>
int main()
{
char a;
printf("enter the character");
scanf("%c",&a);
if(d=='d'){
printf("drum");
}
else{
printf("your input is not valid ");
}
return 0;
}
8.#include <stdio.h>
int main()
{
int num;
printf("enter the value of num");
scanf("%d",&num);
if(num%2==0){
printf("even");
}
else{
printf("odd");
}
return 0;
}
9. #include <stdio.h>
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
if (num % 5 == 0) {
printf("%d is divisible by 5.\n", num);
} else {
printf("%d is not divisible by 5.\n", num);
}
return 0;
}
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
if (num % 10 == 0) {
printf("%d is divisible by 10.\n", num);
} else {
printf("%d is not divisible by 10.\n", num);
}
return 0;
}
int main() {
int num1, num2, sum;
printf("Enter the first number: ");
scanf("%d", &num1);
printf("Enter the second number: ");
scanf("%d", &num2);
sum = num1 + num2;
printf("The sum of %d and %d is %d.\n", num1, num2, sum);
return 0;
}
int main() {
int num1, num2, sub;
printf("Enter the first number: ");
scanf("%d", &num1);
printf("Enter the second number: ");
scanf("%d", &num2);
sub = num1- num2;
printf("The sub of %d and %d is %d.\n", num1, num2, sub);
return 0;
}
13.
#include <stdio.h>
int main() {
int num1, num2, sub;
printf("Enter the first number: ");
scanf("%d", &num1);
printf("Enter the second number: ");
scanf("%d", &num2);
sub = num1- num2;
printf("The sub of %d and %d is %d.\n", num1, num2, sub);
return 0;
}
int main() {
int num1, num2, product;
return 0;
}
int main() {
int num1, num2, remainder;
return 0;
}
int main() {
int num1, num2, ;
return 0;
}
17. #include<stdio.h>
int main()
{
int num1,num2,div;
printf("Enter First Number : ");
scanf("%d", &num1);
printf("\nEnter Second Number : ");
scanf("%d",&num2);
div=num1/num2;
printf("\nDivision of %d & %d is = %d",num1,num2,div);
return 0;
}
#include <stdio.h>
int main() {
int age;
return 0;
}
int main() {
char character;
return 0;
}
19.#include <stdio.h>
#include <ctype.h>
int main() {
char character;
return 0;
}
***********************************************************************************
*****************************************************************
1. #include <stdio.h>
int main()
{
int a = 34;
int b = 4;
int c = 8;
int result = a+(b*b)-c;
printf("%i",result);
return 0;
}
2. #include <stdio.h>
int main()
{
float a = 3.1;
float b = 6.7;
float c = 2.2;
float d = 5.4;
float result = a*b-(c*c)-d;
printf("%f",result);
return 0;
}
3. #include <stdio.h>
int main()
{
float a = 2.3;
int b = 7;
float c = 3.4;
int d = 6;
float e = 2.3;
int f = 2;
float result = a-b+(c*d)-e/f;
printf("%f",result);
return 0;
}
4. #include <stdio.h>
int main()
{
int a = 23;
int b = 2;
int c = 9;
int d = 34;
int result = a*b-c+d;
printf("%i",result);
return 0;
}
***********************************************************************************
**************************************************
1. #include <stdio.h>
int main() {
int day;
if (day == 1) {
printf("Sunday\n");
} else if (day == 2) {
printf("Monday\n");
} else if (day == 3) {
printf("Tuesday\n");
} else if (day == 4) {
printf("Wednesday\n");
} else if (day == 5) {
printf("Thursday\n");
} else if (day == 6) {
printf("Friday\n");
} else if (day == 7) {
printf("Saturday\n");
} else {
printf("Invalid\n");
}
return 0;
}
2. #include <stdio.h>
int main() {
int month;
return 0;
}
3. #include <stdio.h>
int main() {
char ch;
return 0;
}
4. #include <stdio.h>
int main()
{
char a;
printf("enter the value ");
scanf("%c",&a);
if(a=='a'){
int n1,n2,n3;
printf
}
else if(a=='m'){
multiplication
}
else{
printf("input mismatch");
}
return 0;
}
5.#include <stdio.h>
int main() {
int number;
if (number % 2 == 0) {
printf("This number is divisible by 2\n");
} else if (number % 5 == 0) {
printf("This number is divisible by 5\n");
} else if (number % 7 == 0) {
printf("This number is divisible by 7\n");
} else {
printf("Input mismatch\n");
}
return 0;
}
6. #include <stdio.h>
int main() {
int num1, num2;
return 0;
}
7. #include <stdio.h>
int main() {
int num1, num2, num3;
return 0;
}
8. #include <stdio.h>
int main() {
int num1, num2, num3, num4, num5;
9. #include <stdio.h>
float fahrenheitToCelsius(float fahrenheit) {
return (fahrenheit - 32) * 5 / 9;
}
float celsiusToFahrenheit(float celsius) {
return (celsius * 9 / 5) + 32;
}
int main() {
char choice;
float temperature;
return 0;
}
int main() {
char choice;
float temperature;
if (choice == 'c') {
printf("Enter the temperature in Celsius: ");
scanf("%f", &temperature);
printf("Temperature in Fahrenheit: %.2f\n", (temperature * 9 / 5) + 32);
} else if (choice == 'f') {
printf("Enter the temperature in Fahrenheit: ");
scanf("%f", &temperature);
printf("Temperature in Celsius: %.2f\n", (temperature - 32) * 5 / 9);
} else {
printf("Invalid choice\n");
}
return 0;
}
11.
#include <stdio.h>
int main() {
float height_cm, height_m;
return 0;
}
12.#include <stdio.h>
int main() {
int roll_number;
char student_name[50], fname[50], mname[50], address[100], contact[15];
int physics, chemistry, computer_application;
int total;
float percentage;
percentage = (float)total / 3;
char division;
if (percentage >= 60) {
division = 'First';
} else if (percentage >= 45) {
division = 'Second';
} else if (percentage >= 33) {
division = 'Third';
} else {
division = 'Fail';
}
return 0;
}
13. *******************************************************************************
#include<stdio.h>
int
main ()
{
int a, b, c, d, e;
printf("enter the value of a,b,c,d and e : ");
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
if (a >= b && a >= c && a >= d && a >= e)
{
printf ("the maximum number is : %d\a",a);
}
else if (b >= a && b >= c && b >= d && a >= e)
{
printf ("the maximum number is:%d\b",b);
}
else if(c>=a&&c>=b&&c>=d&&c>=e){
printf ("the maximum number is:%d\c ",c);
}
else if (d >= a && d >= b && d >= c && d >= e)
{
printf ("the maximum number is:%d\d",d);
}
else if(e>=a&&e>=b&&e>=c&&e>=d){
printf ("the maximum number is: %d\e",e);
}
return 0;
}
14.#include <stdio.h>
int main() {
float marks, percentage;
printf("Enter marks obtained: ");
scanf("%f", &marks);
// Calculate percentage
percentage = (marks / 100) * 100;
// Display percentage
printf("Percentage: %f\n", percentage);
// Determine grade
if (percentage < 25)
printf("Grade: F\n");
else if (percentage >= 25 && percentage < 45)
printf("Grade: E\n");
else if (percentage >= 45 && percentage < 50)
printf("Grade: D\n");
else if (percentage >= 50 && percentage < 60)
printf("Grade: C\n");
else if (percentage >= 60 && percentage <= 80)
printf("Grade: B\n");
else
printf("Grade: A\n");
return 0;
}