Practical Assignment 1 (A)
Practical Assignment 1 (A)
//Write a program to make addition of two numbers and display the summation.
#include<stdio.h>
printf("summation: %d",a+b);
int main ()
int a,b;
scanf("%d",&a);
scanf("%d",&b);
summation(a,b);
}
––
Defination 2
//Write a program to input Student Name, Branch, Semester, CGPA, and Age and display it.
#include<stdio.h>
void main ()
float cgpa;
int sem,age;
char student_name,branch;
scanf("%s",&student_name);
scanf("%s",&branch);
scanf("%d",&sem);
scanf("%d",&age);
scanf("%lf",&cgpa);
}
Defination 3
// Write a program to display addition, subtraction, multiplication and division of two integers on
screen.
#include<stdio.h>
void main ()
int summ,subt,multi,divi,a,b;
scanf("%d%d",&a,&b);
printf("summ :%d\n",a+b);
printf("subt :%d\n",a-b);
printf("multi :%d\n",a*b);
printf("divi :%d\n",a/b);
}
Defination 4
#include<stdio.h>
void main ()
float pi=3.14,r,area;
scanf("%f",&r);
area=pi*r*r;
printf("%f",area);
}
Defination 5
//Write a program to check whether the entered number is even or odd. (User Define Function)
#include<stdio.h>
void main ()
int a;
scanf("%d",&a);
if(a%2==0)
printf("number is even",a);
else
printf("number is odd",a);
}
Defination 6
//. Write a program to find maximum between two numbers.
#include <stdio.h>
return num1;
} else {
return num2;
int main() {
scanf("%d", &number1);
scanf("%d", &number2);
return 0;
}
Defination 7
// Write a program to Find Maximum from Three numbers.(User Define Function)
#include <stdio.h>
max = num2;
max = num3;
return max;
int main()
scanf("%d", &number1);
scanf("%d", &number2);
printf("Enter the third number: ");
scanf("%d", &number3);
printf("The maximum among %d, %d, and %d is: %d\n", number1, number2, number3,
maximum_number);
return 0;
}
Defination 8
//Write a program to input 5 numbers in an array and display it.
#include <stdio.h>
int main()
int numbers[5],i;
printf("Enter 5 numbers:\n");
for(i=0;i<5; ++i)
scanf("%d", &numbers[i]);
return 0;
}
Defination 9
//Write a program to input 5 subject marks using array and display total marks and average marks.
#include <stdio.h>
int main()
int marks[5],i;
scanf("%d", &marks[i]);
int total = 0;
total += marks[i];
return 0;
}
Defination 10
#include <stdio.h>
max = arr[i];
return max;
int main()
// Declare an array
return 0;
}
Defination 11
//Write a program to input two umbers from user and perform all the basic arithmetic operations.
Here
#include <stdio.h>
int main()
int choice;
scanf("%f", &num1);
scanf("%f", &num2);
printf("\nChoose an operation:\n");
printf("1. Addition\n");
printf("2. Subtraction\n");
printf("3. Multiplication\n");
printf("4. Division\n");
scanf("%d", &choice);
switch (choice)
{
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
if (num2 != 0)
} else
break;
default:
return 0;